22 ms·
Advent of Code 2023 is nigh
- dataengineer56 3y agoIt's a tough day 1, I hope it doesn't scare off too many people. Normally day 1 is just some variation of "add numbers in a list", but this year has a mean pt 2 and a few traps for people to fall into. I wonder how long the global leaderboard will stay up before it gets hidden due to people solving with ChatGPT?
- kristaps 3y agoThis year they politely ask people not to use LLM solutions until the days leaderboard is full.
- ofrzeta 3y agoYeah, usually I get to around day 10 without bigger problems. This year I am already frustrated with day 1 part 2 :-)
- Udo 3y agoI'd actually welcome it if the leaderboard was abolished. I never really played for placement, but something about the fact that the board was full of people who routinely solve every problem in about the same time it takes me to even READ the description was a bit demotivating. I always felt this racing aspect to be somewhat at odds with the idea that this is a challenge that you can complete in your own time, maybe even on weekends, and at the end be proud that you even made it.
- urda 3y agoI tend to agree with this. The leaderboard for many programmers is a source of stress and is another type of internet "comparison" like seeing someone who appears "better" than you on social media. Advent of Code, to me, is a celebration of all the hard work of the year by getting a chance to show off any new skills or abilities you might have picked up. Advent of Code should be about the solve and the sharing of a good problem together, not how fast can you cook a plate of spaghetti.
- pprotas 3y agoI get that some people don’t want to participate in the competition, but how is that a reason to take the feature away from others who enjoy the competition?
- Udo 3y agoIn the context of the larger discussion about how to save the leaderboard in the face of rampant and cheap cheating options, my point was simply that maybe it didn't need to be saved in the first place. Heck, I can't imagine it's actually possible to save it while keeping the event running as it has been. Obviously, there are many people who do enjoy the competition, especially if you're someone who is in the top 10 consistently. But to emphasize it again: arguably, the leaderboard is not as real as you think it is. It's not me who's advocating for taking your achievements from you, it's the state of technological progress that has already done that.
- recursive 3y agoSome people care about the leaderboard, but that's not mandatory. I don't see how the fact of its existence diminishes the experience of someone who never looks at it.
- treesknees 3y agoTo add to this, AoC release its puzzles at midnight ET, so the west coast folks who are still up at 9pm PT will almost always complete the puzzles before someone on the east coast who actually sleeps a regular schedule.
- masklinn 3y agoAccording to several reports, chatgpt can't be made to solve day 1. It's strongly hypothesised that Eric increased the difficulty of the problem specifically to thwart them. Last year they fucked the global leaderboard early, then completely dropped off during week 2, so I can't say I don't welcome it. I didn't find part 2 an issue, but I completely grug-brained it and that was not sensible to the overlap issue.
- w0m 3y agoyay
- anonyfox 3y agoThis year might be the gpt4 speedrun mode. I still prefer to do it manually since casually tackling it is a great way to learn a new language or refresh past knowledge!
- sokoloff 3y agoThe “learn a new language” is how I used it casually for a handful of years (and it’s great for that). Last year is the first year I put serious effort into completing all of it (driven by a private leaderboard which made the accomplishments more personally rewarding). If you’ve got a group of friends/colleagues who could use a little competitive motivation, consider making and joining a private leaderboard (free as in beer).
- ivanjermakov 3y agoSee FAQ on using AI to get to the leaderboard: https://adventofcode.com/about#faq_ai_leaderboard https://adventofcode.com/about#faq_ai_leaderboard. And I wouldn't say day 1 leaderboard is surprisingly fast compared to other years. Time will tell, but I think LLMs will fall apart on hard problems. Typing speed will not be a limiting factor there.
- petercooper 3y agoI decided to give it a go both ways and I found GPT a huge impediment with day one. It did a terrible job and I found it far easier to do myself. I think it's possible to finesse but it'll take more effort than simply "solve this." It didn't help that part two of day one is a fantastic example of a spec causing ambiguity through a lack of detail – I actually wonder if this was deliberate to throw LLM-based approaches off. (Note: There is zero threat of me ever being on the leaderboard as I will never be awake at 5am in December.)
- kristaps 3y agoYeah, that touch of ambiguity looked very deliberate, to give LLMs a hard time.
- kristaps 3y agoLast year there were people solving the puzzles with LLMs, but I don't think I saw anyone get past day 5 or so. I'm interested in how well it goes this year. Please reply if you are trying yourself or can link to public attempts by others
- Mountain_Skies 3y agoPart two of today's problem makes me wonder if they're trying to come up with puzzles that aren't easy for LLMs to complete but might end up making things that also discourage humans from playing.
- tymscar 3y agoOut of curiosity after finishing my solution, I tried it with chatgpt 4.0 Part1 worked after me explaining a tiny bug. Part2 however never worked. Even after explaining exactly where the bug was in the python solution got came up with, it couldn’t fix it. It was quite fascinating watching it try over and over with different approaches, but it couldn’t even get the example working. This just goes to show how good of a puzzle maker Eric is if it stumped gpt4 on day1 when last year gpt3.5 did the first 5 days.
- epiccoleman 3y agoLast year, I used ChatGPT on one of the first puzzles, and ended up writing a blog post about it, where I sort of do commentary on the conversation. It's funny to read this a year later, and filter it through my experiences with ChatGPT over the last year. Some of it still rings true, some of it would probably be much improved with GPT-4. But the places where the LLM fell down in my examples are still the same kinds of issues you get using GPT as an assistant today. If you're interested: https://epiccoleman.com/posts/2022-12-03-chatgpt-aoc https://epiccoleman.com/posts/2022-12-03-chatgpt-aoc
- wdroz 3y agoThe quickest time of the first star is suspicious...
- artzmeister 3y agocommon lispers unite
- tmtvl 3y agoSure, but I'm gonna try and finish 2015's challenges first, something always comes up while I'm working on it, it'd be nice to get it all over and done with.
- stiray 3y agoI am looking at advent of code for years but never tried. Why? As they would like to force you to login with GitHub, Google, Twitter or Reddit account. I will wait for the next year, maybe 2024 Advent of Code will be less intrusive. If not... I can live without it. A hint to the authors for simple load/save, far simpler than what you have now, without use of intrusive 3rd party providers: use Digest::SHA qw(hmac_sha256_hex); $digest=hmac_sha256_hex("levelX:true,...", $key); (And no, I wont workaround them. This is why we got into such situation - as we were still using intrusive services instead boycotting them, it is matter of principle not of technical workaround)
- sokoloff 3y agoIt’s been like this for its duration. I would wager heavily against this changing for 2024.
- redhale 3y agoNot saying I agree with the login requirement, but ... why not just create a throwaway account just for this purpose? This seems like a silly reason to miss out on something you might enjoy.
- skywhopper 3y agoI would hardly call it intrusive. The premise of the game involves tracking stats over days and years, so they need a login system. Using external trusted identity providers is a lot safer for their users than if they tried to implement their own login system. Anyway, don’t hold your breath.
- deleted 3y ago[deleted]
- Xeamek 3y agoParent calls the auth providers (google, github, etc.) as the intrussive ones, not the AoC itself
- fodkodrasz 3y ago
- rschiavone 3y agoOpening up a tab to quickly solve the problem with ChatGPT in order to climb the leaderboard is the modern Tragedy of the Commons.
- kristaps 3y agoTry todays puzzle and let us know how part 2 goes!
- Aurornis 3y agoI suspect they tested their problems against ChatGPT while working on them. ChatGPT doesn’t magically solve everything. There are a lot of cases where it will choke or lead people astray. If I was building a challenge like this in 2023 I’d test the problems against ChatGPT and put the ones where ChatGPT fails at the beginning to weed out the ChatGPT players.
- deleted 3y ago[deleted]
- MandieD 3y agoA bit off-topic, but does anyone know if Hanukkah of Data[0] is happening again this year? [0] https://hanukkah.bluebird.sh/about/ https://hanukkah.bluebird.sh/about/
- saulpw 3y agoWe didn't put another one together this year. But I'm hoping to do another data game sometime in Q1--ideas are brewing.
- berkes 3y agoPart two was exceptionally hard. Many people on reddit reporting they were hit by one edge case that's not covered in the examples. But my implementation passed these edge cases too. I was hit by another edge case. So there are at least two edge-cases (which are in the actual data) that aren't covered in the examples or the description.
- zerr 3y agoGenerally, such edge-cases usually make the solution ugly and the process unpleasant. The aim of such puzzles should be a pleasant process culminating with a beautiful solution.
- randomifcpfan 3y agoThe potential for overlapping numbers was the thing that tripped up many developers. But a simple “find the first number searching from each end, just like the puzzle instructions asked” implementation just worked. The lesson is to read the puzzle instructions carefully and avoid solving more general problems.
- b3orn 3y agoThis is what I did and then was confused why everyone else I talked to thought it was a hard problem.
- codr7 3y agoSame here, I also didn't use the replace-strategy nor regexes.
- berkes 3y agoI did not use regexes, so as said, the most common edge case did not hit me. What hit me was stupid, but also not covered in the example. It was rather implied and obvious from the example, though. SPOILER ALERT In my mistaken implementation `one2three1` would find "1, 2, 3" but not the second case of 1. Now, while the description never explicitly mentioned this, it's still obvious that it should be "11" and not `13`. Though my example, derived by TDD-ing from the example, gave `11`. Only after I diffed my output with that of a known working solution did I find a few lines (there were several of them, though not that much) that made my issue clear: I missed the second case of a number appearing. So "one1one1one" in my solution would only find the first one.
- bryancoxwell 3y agoI think I’d like to try this year’s in a language I haven’t touched before. What languages should I consider if I want something paradigmatically different from Go, Python, etc?
- NateEag 3y agoScheme and Haskell could both be interesting.
- criddell 3y agoProlog or Forth or one of the ML's (SML, OCaml, etc...) come to mind.
- mongol 3y agoI would go for something functional. Haskell? Or possibly Scala
- bnpxft 3y agoScheme https://spritely.institute/static/papers/scheme-primer.html https://spritely.institute/static/papers/scheme-primer.html
- sixstring982 3y agoI built an OCaml starter project for Advent of Code that I've been using. Take a look if you'd like to give OCaml a spin! https://github.com/Sixstring982/tanenbaum https://github.com/Sixstring982/tanenbaum
- icen 3y agoAPL!
- sokoloff 3y agoI used it last year to exercise my utterly novice clojure skills and found that very enjoyable and educational.
- wry_discontent 3y ago
- Waterluvian 3y agoEvery year I want to love this. Every year I get four days in before it feels like work. I think I’m just the wrong audience, but I really do want something this well-produced but with perhaps a very shallow diff little curve, bordering on just effortless fun.
- sundarurfriend 3y ago> Every year I get four days in before it feels like work. Same for me, but I don't think it's exactly about difficulty for me - I've done harder problems on Project Euler, SPOJ, etc., and very much enjoyed them, but somehow Advent of Code doesn't click for me. I think the difference is that there's a lot more "chore" work in AoC problems, compared to Euler or SPOJ where it's mainly about an "Aha" moment figuring out a solution (possibly getting it wrong, going back on it, and getting a different "Aha" moment exercising a different area of your knowledge space).
- sixothree 3y agoAgreed. Games like TIS-100 just feel unrewarding to me because I'd rather be solving my own problems.
- epiccoleman 3y agoI had a similar realization a while back with Factorio. I caught myself watching Youtube videos on how various systems worked and how to optimize things and solve problems, and I just thought... "man, think what I could build if I put this same energy into my programming projects." Still, I like Factorio and similar games, and I'm excited about the upcoming expansion, but it is just kind of funny to notice that it basically feeds on the same kind of drive that I use to build little apps and whatnot, and with those projects, I end up with something a bit more tangible than an elaborate virtual factory.
- brightball 3y agoI interviewed somebody recently for a podcast who is a big AoC fan. His biggest reason is that, if you're learning a new language it's a great way to put it through its paces. He tries to learn a new language every year doing AoC. He's done it with R, Julia, Rust and this year Kotlin.
- zehaeva 3y agoAnother year and another Advent of Code that I don't have enough time in my life to do. One year I'll actually finish!
- weinzierl 3y agoIt's really the worst time of the year for something like this. I hardly remember a time when I wasn't completely swamped with tasks before Christmas. A summer puzzle would be much more doable...
- galleywest200 3y agoThe first half of the month is swamped because everybody takes the second half off of work.
- willsmith72 3y agoplus trying to deal with increased load from christmas shoppers
- epiccoleman 3y agoThe real problem for me is that once the last few days of the puzzle roll around, I'm too busy running around to different Christmas events to have time to squeeze them in. I completed it in 2020 and felt extremely accomplished. I doubt I'll get through all of them this year before losing interest, got too many other projects going, but I always have fun with them.
- gangstead 3y agoThe puzzles are up year round. You can go back and do prior year puzzles any time. There just won't be any of the community from doing it during the event.
- deleted 3y ago[deleted]
- NooneAtAll3 3y agomy screen isn't big enough vertically - on default zoom place for first several days gets hidden below the bottom was so strange to see absolutely empty page until I thought of scrolling down
- brightball 3y agoShameless Plug: If anybody is doing Advent of Code and wants to win tickets to the 2024 Carolina Code Conference (Greenville, SC in August) we're doing a ticket challenge. 22 tickets up for grabs with lots of ways to win. Entry details here. https://blog.carolina.codes/p/advent-of-carolina-code-ticket-challenge https://blog.carolina.codes/p/advent-of-carolina-code-ticket...
- deleted 3y ago[deleted]
- ttrrooppeerr 3y agoI will be doing this advent challenge this year instead: https://adventofchess.com/ https://adventofchess.com/ Looking forward to read your write-ups!
- barrenko 3y agoI'll be doing an Advent of Precalculus, kudos!
- romellem 3y agoInteresting idea, but I can’t even solve day 1 (am short 1 ply for black)! This might be too hard for me…
- classicalhabits 3y agoWooo, love this - thanks for sharing!
- bspammer 3y agoThis looks really cool, but they should make it clearer that you only get one submission per day, and they're not going to check that your answer is valid before submitting. I submitted this (wrong) answer 1. e3 Na6 2. Bxa6 Nf6 3. Bf1 Ne4 4. d4 but only realised afterwards that it has to be _exactly_ 4 moves, less than 4 moves is not good enough.
- gyosko 3y agoAlways relevant: https://www.reddit.com/r/adventofcode/comments/zjwovn/so_youre_trying_to_get_onto_the_leaderboard_huh/ https://www.reddit.com/r/adventofcode/comments/zjwovn/so_you...
- greymalik 3y agoI've never done AoC before. It seems like the success criteria is primarily about getting the correct answer, and secondarily about submitting a solution as quickly as possible if you want to be on the leaderboard. Is that right? Is there any centralized place for seeing other people's solutions? I'd like to be able to learn from how others approach the problem, and what more elegant or performant solutions exist than the one I came up with.
- arberavdullahu 3y agoYou can check the subreddit https://www.reddit.com/r/adventofcode/ https://www.reddit.com/r/adventofcode/ Usually each day there is a mega thread with people sharing their solutions
- masklinn 3y agoA really cool thing about the subreddit is they archive all the megathreads so if you want to do the old advents you can still find some discussion / hints / … Sadly not the various help or complaint threads, or the mad lads playing up the ante, but…
- jehaj 3y agoThe subreddit for advent of code (https://www.reddit.com/r/adventofcode https://www.reddit.com/r/adventofcode) has a thread for each day where people share their solution.
- Avshalom 3y agosubmitting as quickly as possible is very much not a success criteria. Each problem becomes available midnight EST so unless you're a competitive weirdo you won't even see the problem until the leaderboard is full.
- justinsaccount 3y ago> the success criteria The the success criteria is whatever you want it to be. * Learn a new language * Practice a language you already know * Try to solve things in a small number of lines * Try to solve things where the solutions run as fast as possible * ... any number of other personal goals * Try to make the leaderboard I've been solving the older years and learning rust in the process. I made it a secondary goal that all 49 solutions should be able to run in under 1s total. 2015 was easy, 2016 less so.
- vincent_b 3y ago[dead]
- deleted 3y ago[deleted]
- rrishi 3y agoGenuinely curios why people are so into AoC ... Feels leetcode-y
- 63 3y agoIt's more whimsical. There's a clear end with less pressure and an excited community to discuss with. At least that's what it's like for me (though I do also enjoy leetcode occasionally to be fair)
- epiccoleman 3y agoAt least for me, it's like... infinitely more fun than leetcode. The problems are bite-sized enough that I can usually get something done in less than an hour (although usually there's at least a few in the mix that take a long time to finish). There's a lot of personality in the website and text of the events that add to the fun factor. I like how the problems are broken up into two phases and how the second phase often throws a wrench in my previous solution or forces me to learn some tricky thing to get by.
- fodkodrasz 3y agoWhen it was done in a private leaderboard in a traditional in-person team working in the same office it was a great watercooler talk topic and code-golf team building topic. I tried to do it in a remote work team with weaker personal links, and it felt like a chore, so this year I'm not doing it at all. No fun without the in-person code reviews and pair-programming code golfing. Also many of us tried new languages of paradigms every year.
- room500 3y agoA few reasons I like them: 1. The goal is to come up with a workable solution - not to try to fold your brain inside out to optimize them like leetcode. They feel a little more "real-world" (though still firmly in the domain of programming puzzle) 2. There is a community that all solve them at once. At my company, we have a leaderboard and a Slack channel discussing them every day. And then there is the Reddit and everything else that makes it feel more "fun" 3. They are bound (only 1 problem a day). Some days are longer, but I don't get overwhelmed like I do with leetcode where you can lose hours just churning through problems. IMO, they are a fun community programming puzzle tradition. I would still turn to leetcode for interview practice. But AoC is awesome for me when I don't want to grind leetcode for some interview I don't want right now.
- 63 3y agoDay one part 2 was relatively rough. Things I learned from it: rust regex crate doesn't support look-ahead, rust onig crate is currently broken in many ways and shouldn't be used (the version in crates.io doesn't compile and the version on GitHub is failing tests and look-ahead isn't working). It was a very frustrating time for me. After 2 hours of troubleshooting the above I used the same approach in python and it took 2 minutes to write. So annoying.
- burntsushi 3y agoRust regex crate author here. fancy-regex is built on top of the regex crate and supports look-around. The regex crate doesn't support arbitrary look-around because it isn't known how to implement efficiently. See: https://swtch.com/~rsc/regexp/regexp1.html https://swtch.com/~rsc/regexp/regexp1.html
- j1elo 3y ago> The regex crate doesn't support arbitrary look-around because it isn't known how to implement efficiently. A bit of a philosophical question: If how to write an efficient implementation is yet not known to man, ie. not a matter of the library's author time or skills, but literally a limit on human knowledge: why not at least provide the functionality with a good enough implementation? (with caveats just possibly mentioned in documentation) IMHO that'd be arguably a good thing for everybody, at a minimum better than just not offering the possibility at all. Which drives users to frustration, or leaves them having to discover a more pragmatic alternative lib that opted to add it. This is no complaint or feature request... I just want to learn from some insight behind the thought process of "if it's not efficient, better not have it at all" PS. Thanks for the link. Now I have a good read for the weekend, for sure!
- fsociety 3y agoBecause it is a mechanism for ReDOS, and the standard library should not be introducing vulnerabilities into users. Other libraries can implement it for folks who decide they really need it.
- shever73 3y agoAs others have said, part 2 of today's was really difficult. I finally solved it using Python regex `overlapped=true`, but it was very tricky. The irritation of having all of the test cases passing, but it failing for my challenge input! I hope it doesn't scare off newcomers, but I already know a few who have given up on part 2.
- jjice 3y agoSame here. I would've really like if the spec specifically mentioned the possibility of that one edge case ahead of time instead of having to sift through the 1000 lines of input. No hate on AOC though, I really respect all the hard work that goes into it.
- frantathefranta 3y agoYeah I was sort of lucky that my edge case was on the last line, still took a full hour of wondering why my solution was wrong though.
- wjholden 3y agoWhat was this edge case you encountered? My code worked...after I finally read the problem closely enough.
- shever73 3y agoFor me it was a lack of specific instructions on how to handle overlaps. The edge case that frustrated me for a while was "oneight" at the end of a line. My initial code made it look like this "1ight", when it should have been "18".
- WJW 3y agoWhen searching for the last number in the line I just reversed the line and scanned through it looking for the reversed strings for the number: one -> eno two -> owt three -> eerht etc It makes the entire solution extremely simple, though a little verbose.
- bradley13 3y agoSeems to me that people made part 2 harder than it us. Just define an array containing the digits: "one", "two", and so forth. Then check for substring matches, position by position. Maybe not elegant, but effective.
- Vingdoloras 3y agoI just placed digits in the middle of the words instead of replacing them. This way I didn't "break" any overlapping words, and the order of digits is still the same.
- bauble 3y agoI think the issue is that they tried to separate the input into a list of tokens, like ["5", "nine"], and work from there, which doesn't work on something like "oneight".
- Maxion 3y agoIt's funny how all of us used the `oneight` as the edge case to test our code on...
- jes5199 3y agoI used "eightwo"
- kemyke 3y agoBut a simple replace if you do it like this .Replace("one", "on1e") or .Replace("eight", "eig8ht") Not elegant but still do the job.
- xdavidliu 3y agoI didn't have that issue at all; I just looped through the 20 different tokens and found first and last instances of all of them, and compared the very first and very last of all instances. https://github.com/xdavidliu/advent-of-code/blob/main/2023/day02.cpp https://github.com/xdavidliu/advent-of-code/blob/main/2023/d...
- aaaronic 3y agoI think the edge cases were entirely unclear in day 1, part 2. I had to redo it in a "dumb"/brute-force way to avoid using fancy regex tricks I don't know. It's quite clear the small sample data was chosen intentionally to not cover them.
- adbachman 3y agothat's interesting. my example data did include the edge case that caught me out in part two, but didn't include it in a way that broke my first pass at a solution. funny piece is it didn't click until i submitted a wrong answer, read my code for a few minutes, added a bunch of logging, and then saw the trick. i looked back at the given example and it was right there the whole time, just not called out explicitly.
- WJW 3y agoThe problem statement was super clear though. "Find the first occurrence of any one of these strings in a longer string" doesn't require any fancy regex tricks, just a for loop and knowledge about `isPrefixOf` or `startsWith` or whatever the equivalent function is called in your language of choice. "Find the last occurrence of any one of these strings in a longer string" is just the first problem again but with all the strings reversed.
- masklinn 3y ago> knowledge about `isPrefixOf` or `startsWith` or whatever the equivalent function is called in your language of choice. There's no guarantee the digits are the first or last, so it's more `find` and `rfind`, unless you try every subslice of the line by hand. Although thinking about it assuming the lines are not too long I guess that also works.
- DylanDmitri 3y agoI looked at the slices from each position to the end. Now for every name (“one”, “1”, “two”, …) check slice.startswith(name). After I pulled out first and last from results array. Two nested for loops, program all included was under twenty lines.
- deleted 3y ago[deleted]
- laweijfmvo 3y ago> failed to authenticate. (access_token request returned 429 Too Many Requests) Hope it's just a temporary issue!
- racoonportfolio 3y agoYou're not alone
- thekr1s 3y ago+1 here failed to authenticate. (access_token request returned 429 Too Many Requests)
- Chobilet 3y agoWithout going into spoilers, its interesting that people jumped to regex to solve this. For me that was a fairly non intuitive when I first saw the problem(both parts). What jumped to me is the problem statement indicated a finite number of states and I crafted a solution based on that information. But its really cool to see how we all jump to different implementations.
- deleted 3y ago[deleted]
- nick0garvey 3y agoI also started to write a finite state machine for part 2 but found it too tedious to craft by hand. How did you do it?
- criddell 3y agoNot OP, but I too first thought of a state machine. As soon as I started to write it I realized I was over-solving a day-1 problem. So I switched to brute force https://pastebin.com/r1jNCSdm https://pastebin.com/r1jNCSdm Once I get a line back from that, it's the same problem as part A.
- Chobilet 3y agoSorry all, I misused the word finite state. I meant it more from a combinatorics viewpoint(e.g. we only have X amount of operations per Y interval). You could consider my solution to be brute force code. Abstractly I do this: read_file() lines = read_lines() sum = 0 while lines: left = get_first_num_forwards(line) right = get_first_num_backwards(line) sum += integer(left+right) return sum I define get_first_num() something like this: get_first_num(line): lowest_index_pair = None for key,val in dict.values(): get_index_of_key_if_exists() if_exists: update_lowest_index_pair() index,num find_first_instance_num() //just gets the first num that appears update_lowest_index_pair() return lowest_index_pair[1]//just returns the number Basically the idea is very similar to yours. We parse each line 11 times in both direction(10 per the word_vals dict and once more to find the index of the first numerical) which is only 22 parses. Then we grab the minimum index from this list and concat with the opposite side. I just don't do any replacements at the cost of a longer run time. But I figure the cost of 11 parses was low enough that it wouldnt impact the run time significantly for this exercise. The key point is that overlaps are not an issue because we check for string comparisons in the methods
- sertbdfgbnfgsd 3y agoMaybe I'm too stupid for this > Consider your entire calibration document. What is the sum of all of the calibration values? Where is the document? Where do I download it?
- drunner 3y agoThe very next line is "To begin, get your puzzle input." with a link
- sertbdfgbnfgsd 3y agoAhhh. I have > To play, please identify yourself via one of these services: Ok got it. Turns out I am too stupid.
- nikolay 3y agoPython should be excluded! I force myself to use Go, but it's just not competitive.
- codr7 3y agoI like powerful languages without a too many built in convenience features. That way I get to enjoy solving the problems myself without too much effort.
- nikolay 3y agoSome of the solutions are quick and dirty, mostly dirty. And that's not art, but programming kitsch.
- codr7 3y agoIt is what you make it. I admire the ability to brute force problems using the most convenient features available as much as anyone, especially professionally. But to me, this is about evolving as a programmer; I do enough duct taping at work.
- kif 3y agoI don't know if I'll even bother this year. Their puzzles start feeling like chores by the 10th problem or so and I drop out. Maybe I'll learn a new language to spice it up this year.
- mmebane 3y agoI tried AoC for the first time last year, and that was pretty much my experience. A week or so of easy problems, then 1 or 2 that were still pretty straightforward but a bit more tedious, then 1 that was a lot more work because you were supposed to derive some of the rules from the example. I don't think it would've been too hard, but like you said, it was starting to feel like a chore at that point, so I stopped.
- Icathian 3y agoEach year I do it until it no longer sparks joy, and then stop. I usually make it about 2 weeks. I don't see anything wrong with that. I'm using this year's to dust off my Rust skills in advance of a new job using that language, so that's nice too.
- codr7 3y agoFor me it's a convenient excuse to write some Lisp and I often learn something by looking at other solutions once I've had a go myself.
- 0x264 3y ago> like chores by the 10th problem or so and I drop out That they get so involved is the reason I participate (despite also working at the same time). I love the fact that the difficulty starts low and then goes up to levels where I feel really challenged. It's a month (well, 25 days) commitment which pays off the entire 11 other months for me :)
- trymas 3y ago> Their puzzles start feeling like chores Advent of chore ? :) ..though I agree - never went past 10th day or so.
- AdamH12113 3y agoAdvice from 7 years of doing (and sometimes completing!) the Advent of Code: 1. Look at the example input. 2. Run your code on the example input. 3. Seriously -- make extra super 100% sure your code works on the example input. Write some boilerplate code to make it easy to switch between your input and the example input. 4. Think about possible edge cases in the input -- there will probably be some. Looking at your input in a text editor can help uncover them. 5. If part 1 is simple, it's just there to test your input processing, and part 2 will be the real puzzle. 6. If part 1 is solvable with brute force, part 2 probably won't be. But sometimes it's helpful to brute-force part 1 just to see what the question is. 7. Many problems that involve the word "shortest" or "fastest" are good candidates for a breadth-first search. Make sure you know how to do that. 8. Test your code as you go. Printing the output of intermediate steps to the console is a great way of catching bugs. 9. There's going to be some hideous puzzle, probably involving a maze, which is too hard for a simple BFS and requires heavy pruning of alternatives. If you know how to do this kind of puzzle, please tell me how; they get me every time. :-( 10. Don't even look at the leaderboard times. Those people are nuts.
- deleted 3y ago[deleted]
- epiccoleman 3y ago> Run your code on the example input. > Seriously -- make extra super 100% sure your code works on the example input. Write some boilerplate code to make it easy to switch between your input and the example input. > Test your code as you go. Printing the output of intermediate steps to the console is a great way of catching bugs. Honestly, just set up whatever you need to be able to write unit tests in your lang of choice. These problems are _so_ amenable to a piecewise approach driven by tests. I'm not like a big TDD advocate or anything, but these problems are great practice for that style of coding - it's just so damn useful to know each of your small pieces of code work. Parameterized tests are amazing for AoC, because you can get a handful of test cases basically for free from the puzzle description. If your code doesn't work once you've got all the samples working, you either have some weird edge case that you didn't consider, or you've got one of the brute-force killer puzzles. Even for today's, I wound up with 43 different test cases. The vast majority of those are from the puzzle text, and adding them didn't really make the puzzle take that much longer. (Obviously, if you're optimizing for solve speed, you probably wouldn't bother with this approach, but I'm not). https://github.com/epiccoleman/advent_of_code_ex/blob/master/test/aoc_2023/day01/day01_test.exs https://github.com/epiccoleman/advent_of_code_ex/blob/master... Another thing of note is that every puzzle basically operates on a list of strings, so it's pretty easy to genericize certain parts of the work of solving puzzles. I have a script which generates a module for the solution in my repo, with separate functions for each part that receive the input, and a test file that has tests for part 1 and part 2. The tests read the input file and pass it as a list of strings (lines) to the part_1 and part_2 functions, so that all the boilerplate is already done, and I get to just focus on writing the guts of the part_1 and part_2 functions (which usually get broken down into several other functions, which can also be tested individually).
- deleted 3y ago[deleted]
- ohnoerik 3y agoI'm going to see how far I can go with Terraform this year. Part 1 was fine, but Part 2 was a bit challenging at first.
- fodkodrasz 3y agoHi! Would you care to share these experiments with us? I'm really interested in extreme attempt! Have Fun!
- imperialdrive 3y agoGosh I'm feeling extra special this morning as an absolute infant beginner tinkerer that figured solution in powershell to part II after a few minutes of closing my eyes, but I highly doubt I'll be able to say that about the next one if they get harder. The example was so excellently written though, which helped a ton.
- Tainnor 3y agoDay 1 part 2 was harder than is common for the first day. I ended up using parser combinators (attoparsec for Haskell), which morally feels like the "right" way to do this (so you don't have to manually keep track of how much you've read or somehow abuse regex lookaheads), but I don't know the library well and it took me some time to implement it correctly.
- deleted 3y ago[deleted]
- Liam2010 3y ago[dead]
- calibas 3y agoPart 2 seemed fairly easy until I noticed "twone". I used Rust and match_indices to get the answer.
- Foivos 3y agoThe main difficulty of part 2 is that there are edge cases that are not covered by the examples. I have appended the example list with some edge cases, so use this list instead: two1nine eightwothree abcone2threexyz xtwone3four 4nineeightseven2 zoneight234 7pqrstsixteen eighthree sevenine oneight xtwone3four three7one7 eightwothree oooneeone eight7eight
- codr7 3y agoI don't get the amount of effort people out into the replacement-strategy, I did perfectly fine without it and the code is about as complex as the examples I've seen. https://github.com/codr7/swift-interpreter/blob/main/part10/aoc/code2.lisp https://github.com/codr7/swift-interpreter/blob/main/part10/...
- Levitz 3y ago>replacement-strategy Oh so THAT is what is causing people problems.
- brynbryn 3y agoAhh, people are trying to do a replacement before finding tokens. I wondered why so many people were saying this was difficult. My head went straight to token parsing, which given the limited set of tokens made it trivial. Thought I was missing something
- skydhash 3y agoI think people with understanding of compilers always want to model their code as DSL, and that makes it easier to go for backwards scanning.
- deleted 3y ago[deleted]
- messe 3y agoYeah, all the talk of replacement seems like people masively overthinking or abstracting a day one problem. My C++ solution was a simple search using the <algorithm> header. It's a little less neatly abstracted out as yours, and could be cleaned up a fair bit, as I wasn't bothered to deduplicate the code after getting it working (and I will if this turns out to be useful tomorrow), but the essence is the same: https://gist.github.com/joedavis/3d6f2b87bae4809ef8a062caff756119 https://gist.github.com/joedavis/3d6f2b87bae4809ef8a062caff7... C++'s .rbegin() / .rend() reverse iterators made the search fairly trivial.
- CobrastanJorji 3y agoAdvent of Code means a lot to me. The problems are fun, sure, but something about it really boosts my winter. I've noticed that I get a lot more productive with my hobbies in the weeks following AoC. I think maybe it's as simple as living on the west coast and getting used to getting amped and doing some big, adrenaline-filled, social, fun activity at 9 PM every night. It gets me used to being PRODUCTIVE in the evening and not just settling down to watch TV. Anyway, whatever the cause, I care a lot about AoC. It makes my Decembers a whole lot happier.
- matsemann 3y agoFor me it's the same, but opposite. It forces me out of bed and ready by the computer at 6 in the morning, haha. Which of course also means that I can end early and suddenly have so much evening time.
- codr7 3y agoMost solutions I see are just blobs of code, which makes me wonder what their process looks like. I like to solve these kinds of problems in Lisp, which means I'm working in a REPL and dividing and conquering the problem to be able to test one piece of the solution at a time. The result is that my code tends to be mainly independent functions that I finally string together to solve the problem.
- icen 3y agoI'm solving in BQN, and my workflow is repeatedly re-phrasing a line until it does what I want in the repl, and then naming it, and then moving on. Most often I end up with some enormous one-liner that I then break down into functions again.
- jsmeaton 3y agoSome folks on the subreddit will stream and then post their solutions so you can see their process. I usually enjoy watching Jonathon Paulson solve a problem after I’ve got my solution submitted. He features quite high on the leaderboard each year. https://youtu.be/rnidYOt9m2o?si=ND_FyUJTIe-dBNrT https://youtu.be/rnidYOt9m2o?si=ND_FyUJTIe-dBNrT
- ni507 3y agoAs every year, I stumbled upon the Advent of Code, but this year was a bit different as I found a way to solve the puzzle using our API client. The other years I got demotivated very quickly as I had to create some I/O functions, copy the files, etc. So I came up with the idea to solve it using Kreya's scripting feature and it was a joy. Created a blog post [1] as maybe other people feel the same way :) [1] https://kreya.app/blog/solving-advent-of-code-with-kreya/ https://kreya.app/blog/solving-advent-of-code-with-kreya/
- matjazdrolc 3y agoI ended up using parser combinator library nom. It's not something I use daily, therefore parsing became a puzzle on its own. Nom already has a parser for numbers. However, I didn't find an elegant way to take at most one digit. In the end I used take_while_m_n, and mapped it with u64::from_str(). Another challenge was absence of something such as find_all, that would repeatedly try to parse beginning from each character and then return all matches. I ended up writing my own combinator. https://github.com/drola/AdventOfCode2023/blob/main/src/bin/day_01_trebuchet.rs#L37 https://github.com/drola/AdventOfCode2023/blob/main/src/bin/...
- woile 3y agoNice! I also ended up using nom, it was quite fun. https://github.com/woile/adventofcode/blob/main/2023/day1/src/main.rs#L11 https://github.com/woile/adventofcode/blob/main/2023/day1/sr...
- V41frQo1SccpfHI 3y agoWow thanks, I was stuck with the iterating part and your solution really helped me :)
- gh123man 3y agoI challenge myself to do it in bash one liners. I came up with a clever and shockingly simple solution to part2 using expansion and substitution. cat 1.txt | sed -E 's/(one)/\11\1/g; s/(two)/\12\1/g; s/(three)/\13\1/g; s/(four)/\14\1/g; s/(five)/\15\1/g; s/(six)/\16\1/g; s/(seven)/\17\1/g; s/(eight)/\18\1/g; s/(nine)/\19\1/g;' | sed -e 's/[^0-9]//g' | awk '{print substr($0,1,1) substr($0,length,1)}' | tr '\n' '+' | sed 's/\(.*\)+/\1\n/' | bc
- usgroup 3y agodoes it deal with cases like "twone", "nineight" and so on? it doesn't appear so to me because of the leading sed statements would commit the interpretation regardless of what happens next, but perhaps there is something subtle im not seeing.
- matsemann 3y agoIt uses capture groups and puts them back in the replacement (the \1 ), so a match of "one" is replaced with (thematch)1(thematch). So eightwo would replace the two with two2two and end up like eightwo2two, so then the t is preserved and eight is found in a later step and then you end up with eight8eightwo2two, and can solve that using part1 only looking for numbers.
- usgroup 3y agoI see. Thank you for the explanation. I didn't know about that feature of sed.
- jes5199 3y agookay that's very clever
- matsemann 3y agoFor my own I did the same, but without capture groups. So replaced "one" with "one1one" naively without regex and did that for all numbers. While it maybe is post-hoc clever, I think most of us ended up there because we tried naively to just replace "one" with "1", which broke on things like twone. So when down that path one had to amend it instead of going somewhere else.
- cannabis_sam 3y agoMan, this feels like a frustratingly good way to get back into Haskell, and on the cutting edge of GHC to boot… Or should I take the plunge and do it in rust? (If only I was unemployed and could do this in agda/idris/lean…)
- xdavidliu 3y agoI did 2016 in Haskell and 2018 in Rust. Haskell was kind of a pain since I had to do a ton of tail recursion. Rust would be a lot easier since it allows you to be imperative when you need to. And I definitely only used a tiny subset of either language because I wanted to get the solution as quickly as possible. [1] https://github.com/xdavidliu/advent-of-code/tree/main/2016 https://github.com/xdavidliu/advent-of-code/tree/main/2016 [2] https://github.com/xdavidliu/advent-of-code/tree/main/2018 https://github.com/xdavidliu/advent-of-code/tree/main/2018
- usgroup 3y agoA Prolog Definite Clause Grammar (DCG) solution: https://github.com/emiruz/adventofcode2023/blob/main/day01/part2.prolog https://github.com/emiruz/adventofcode2023/blob/main/day01/p...
- deafpolygon 3y agoI solved the 2nd part pretty neatly in javascript today... I'm not a great programmer by any stretch but, maybe someone can take a peek and tell me what I can improve? This is my first time with JS-- I dislike the idea of it, but I know I should program in it before I write it off. https://github.com/deafpolygon/advent-of-code/blob/main/2023/day01/index.js https://github.com/deafpolygon/advent-of-code/blob/main/2023...
- drewcoo 3y ago"Nigh" is off by at least one, depending when this is all read.
- vacuity 3y agoConsider it a distributed systems synchronization problem.
- subset 3y agoFirst time trying a code golf solution, managed to do Part 2 in 231 characters. p="one two three four five six seven eight nine".split();sum(int(x[0]+x[-1])for x in["".join([["",s[0]][s[0].isdigit()],str(p.index(w)+1)][s.startswith(w)]for s in[l[i:]for i in range(len(l))]for w in p)for l in open("input.txt")])
- mikewarot 3y agoIn times past, it was Pascal that was my language of choice[1]. This year, I'm going to use a virtual BitGrid[2]. Here's the repo[3] Hopefully I can finish the 2023 problems before next November, I have nothing but the simulator. Nothing to convert text to code, do I/O, etc. Oh boy.... Day 1 A... and I have to figure out how to feed text into a bitgrid, and get it out the other side... before I can even think about parsing it, making integers, and adding them, then converting back to text. BitGrid - a sea of LUTs with latches, completely parallel down to the bit processing. Each LUT has 4 bits of input, and 4 independent bits out to each cardinal direction. Clocking in 2 phases, like colors on a chess board, to eliminate undefined behavior or timing issues. [1] https://github.com/mikewarot/Advent_of_Code_in_Pascal https://github.com/mikewarot/Advent_of_Code_in_Pascal [2] https://github.com/mikewarot/Bitgrid https://github.com/mikewarot/Bitgrid [3] https://github.com/mikewarot/Advent_of_Code_in_BitGrid https://github.com/mikewarot/Advent_of_Code_in_BitGrid