[HN Gopher] Advent of Code 2021
       ___________________________________________________________________
        
       Advent of Code 2021
        
       Author : amenghra
       Score  : 662 points
       Date   : 2021-11-20 23:41 UTC (23 hours ago)
        
 (HTM) web link (adventofcode.com)
 (TXT) w3m dump (adventofcode.com)
        
       | ZiiS wrote:
       | Looking forward again. The puzzles are good, but they are
       | described so well they become a real joy to solve.
        
       | mordechai9000 wrote:
       | So for the first time in years, we are leaving for the holidays
       | (in-laws). I was going to use the time off (and the inevitable
       | boredom) to get an AWS cert to help my job search. Now I don't
       | know...
       | 
       | In the past, I've given up on AoC after a couple weeks due to
       | time and conflicting priorities. With two whole weeks of free
       | time that coincides with the hardest puzzles, I guess I know what
       | I'm doing in December.
        
       | thom wrote:
       | Tried this properly for the first time last year, and very much
       | enjoyed doing each task 'properly' with literate programming,
       | unit tests, benchmarks for different implementations etc. It was
       | extremely soothing, much more so than if I'd just tried to solve
       | each problem as quickly as possibly. I'm sure some others would
       | get a lot out of this approach, whether or not you're trying a
       | new language.
        
         | jstx1 wrote:
         | > unit tests
         | 
         | Don't you need a way to generate more inputs in addition to the
         | one you have?
        
           | a_humean wrote:
           | Every puzzle comes with example inputs and expected outputs.
           | Those inputs are much smaller than the puzzle input, but if
           | you get the example inputs and expected outputs right then
           | you are probably most of the way there.
           | 
           | Basically every puzzle comes with unit tests that just need
           | to be translated into code.
        
             | someuname wrote:
             | Those would be functional tests
        
               | jacobmischka wrote:
               | Same thing if your whole solution is a single function :)
        
               | NoahTheDuke wrote:
               | Which is another name for unit tests.
        
             | thom wrote:
             | Yup, although I do enjoy finding edge cases that aren't
             | necessarily present in the examples or input. I intend to
             | do a fair bit more property-based testing this year, just
             | for kicks. That's something I've had success with for raw
             | algorithmic code but struggled with in the past for nitty-
             | gritty real-world use cases.
        
       | francisduvivier wrote:
       | Oooh, so excited, last year I also wrote a little discord bot
       | that can run on a raspberry pi zero written in plain JS. So
       | shameless plug here: https://github.com/francisduvivier/aoc-
       | discord-notifier-bot
        
       | divtiwari wrote:
       | Would OCaml be a good language to use here? It would be my first
       | time in AoC, want to learn OCaml as well.
        
         | dunefox wrote:
         | Absolutely. But I suggest learning it a couple of days
         | beforehand just to know the tooling and the language enough to
         | get started. A cold start with AoC is quite hard.
        
           | divtiwari wrote:
           | Thanks for the advice, would start from today!!
        
         | kingaillas wrote:
         | Sure, but start right now solving a few problems from previous
         | years.
         | 
         | You'll want to know how to open and read a file, parse input
         | (generally line by line, splitting each line on spaces), get
         | familiar with data structures such as the dictionary/hash map
         | and how to use the OCaml version. Not that you'll be competing
         | for the leaderboard; this is more about getting familiar with
         | the typical things for solving each problem.
        
           | divtiwari wrote:
           | Thanks for the advice
        
         | skhm wrote:
         | as good as any :)
        
         | auxym wrote:
         | Yes! However, I'll say this: If you're using a new language
         | that you're trying to learn, _don 't_ also try to do it for
         | time. That is to say, take your time, it doesn't matter if it
         | takes you a few days to do a single problem. Do try and read
         | other people's solutions in OCaml after you've solved it
         | yourself, or even before, if you're really stuck.
        
           | divtiwari wrote:
           | Thanks for the advice!!
        
       | begueradj wrote:
       | Really cool design and content.
        
       | andy_ppp wrote:
       | I did this last year and loved it, if you aren't even considering
       | it I would, it made me a better programmer and it allowed me to
       | go from completing around 60% of in interview coding tests to
       | maybe 90%+. I'm not scared of them like I used to be either. If
       | people do this for fun it's also probably worth hiring them...
        
         | jstx1 wrote:
         | It would be great if that was true but I would still feel kind
         | cheesy putting it on my CV. That might just be my own biases
         | speaking though.
        
           | andy_ppp wrote:
           | That's why you put it on your GitHub.
        
       | [deleted]
        
       | sundarurfriend wrote:
       | I'm going to try Crystal[1] this year, now that it's had a 1.0
       | release. At least for the first 10 problems - after that, I'll
       | likely switch to Julia unless Crystal proves to be even more
       | enjoyable than I expect.
       | 
       | [1] https://crystal-lang.org/
        
       | aquova wrote:
       | It's nearly upon us once again!
       | 
       | I've (somewhat) participated the last few years, more as a way to
       | learn new languages, I've never actually made it through all the
       | puzzles yet. I got fairly close with Rust last year, before
       | getting burned out by the end. I'm currently debating either
       | doing it with Nim or Ruby, of which I've never written a single
       | line of in my life, but I'm curious to try out.
        
         | bashbjorn wrote:
         | I did AoC in Nim one year and was very happy with it! I also
         | became infatuated with Nim that year..
        
           | auxym wrote:
           | I also learned Nim in 2018 with AoC. I found one of the best
           | things was coming up with my own solution, then looking at
           | other people's solutions (the Nim community usually does
           | Advent of Nim where a bunch of people post their solution
           | repos on the nim forum) for more idiomatic approaches or
           | stdlib functions I didn't know about.
        
             | otherme123 wrote:
             | Solutions made with https://github.com/zevv/npeg were
             | surreal, I felt like a caveman watching a TV.
        
               | auxym wrote:
               | Yes, I do distinctly remember having that same feeling
               | when reading zevv's solutions!
        
         | pietroppeter wrote:
         | I have discovered Nim on this (HN) site in 2018 [0] and shortly
         | after I wrote my first lines of code thanks to advent of code
         | (it was also my first year discovering advent of code).
         | 
         | I have become so affectionate of both (Nim and Advent of Code),
         | that I always look forward to this moment of the year!
         | 
         | Last year I used it to test my notebook library nimib [1] (and
         | it was first, and currently only, year that I completed the
         | calendar). This year a nice challenge could be to try and use a
         | different library from Nim ecosystem each day (always wanted to
         | use Nico for this, Manim looks it could give nice results,
         | ...).
         | 
         | [0]: https://news.ycombinator.com/item?id=18045259
         | 
         | [1]: https://pietroppeter.github.io/adventofnim/2020/day11.html
        
         | GavinMcG wrote:
         | Also hoping to do it with Nim!
         | 
         | Last year I'd asked for some getting started advice here:
         | https://www.reddit.com/r/nim/comments/k22h74/advent_of_nim_2...
        
       | porknubbins wrote:
       | Now that I finally learned what a modulo multiplicative inverse
       | and how to compute one is it will probably be the year that it
       | doesn't come up.
        
       | Torkel wrote:
       | Best advent of code I've done was the "int-code computer" one. So
       | good - one recurring theme of making a computer and in the end
       | running games on it! Super excited for this year's edition :)
        
         | a20eac1d wrote:
         | That sounds amazing, is there any way to access this material
         | right now?
        
           | NLips wrote:
           | You can see any year by changing the url:
           | https://adventofcode.com/2021
           | 
           | I think it started in 2015.
           | 
           | On the AoC website you need to provide solutions for each day
           | in a given year to see the next day's problem, so you can't
           | instantly see all the problems from a given year unless
           | you've previously completed them.
           | 
           | You may be able to find the problems elsewhere on the net.
        
             | forgotpwd16 wrote:
             | All problems are available as long as their day has come
             | even while the event is running. But the part 2 of each
             | problem requires solving part 1 first.
        
               | NLips wrote:
               | Hah - I've assumed for years that days weren't accessible
               | because the section of ASCII art for them is greyed out!
        
           | wodenokoto wrote:
           | you write the intcode computer in AoC 2019
           | 
           | https://adventofcode.com/2019
           | 
           | Not everyday is about intcodes, but day 2, 5 and 7 are the
           | first 3 days with intcodes and they built on top of
           | eachother.
        
         | breckenedge wrote:
         | I agree. That year was the only one in which I completed all of
         | the puzzles the day they came out.
        
         | guavaNinja wrote:
         | Here is one for 2019 https://adventofcode.com/2019/day/2
        
         | viceroyalbean wrote:
         | One of my favorite things about the intcode computer was
         | implementing the extendable memory by just appending an
         | infinite list of zeros using haskell's lazy evaluation.
         | 
         | Unfortunately my implementation was incredibly slow (probably
         | because of the linked lists) and I only made it about halfway
         | through.
        
           | 1-more wrote:
           | Was this 2019? I did half of it in elm. Simulating a
           | processor with the core states of read, eval, and write was
           | very cool. Using setTimeout to send it clock signals was very
           | slow until I realized I could compose the processor step
           | function to run a few thousand clock cycles per timeout. Wild
           | time.
        
           | gameswithgo wrote:
           | my fun thing was running my intcode computers in parallel
        
           | CornCobs wrote:
           | I also did that year in haskell! My favorite part was using
           | knot tying to feed the output of my intcode machine into
           | itself! Lazy evaluation allowed me to continue expressing my
           | intcode machine as a pure function of [Int] -> [Int] without
           | having to restructure the entire machine to allow getting an
           | output, then adding the next input to the machine in a step-
           | wise manner usually accomplished with generators of some sort
           | in other languages
        
         | wodenokoto wrote:
         | Having never written anything close to a parser or a compiler,
         | I totally crashed on that one. I often misunderstood subtleties
         | in the problem formulation and had to read solutions in order
         | to figure out the question and ended up with such a mess of if-
         | else statements for compiling int-codes that it just became
         | impossible to extend my program.
        
           | nikanj wrote:
           | But now you have written one, which might come in handy at
           | some point in your career.
        
             | wodenokoto wrote:
             | Well, I guess I know now how not to write one ;)
        
               | wbc wrote:
               | way to sum up my coding career :D
        
         | dunham wrote:
         | That was my first and my favorite so far. I did it in Haskell,
         | barely knowing Haskell, which made things a bit interesting. I
         | ended up learning/using STArray for the memory.
        
       | skruger wrote:
       | For inspiration, here's the full solution set for the 2015
       | edition in around 100 loc of k. Yes, all problems.
       | 
       | https://github.com/KxSystems/kdb/blob/master/ad.k
        
         | IshKebab wrote:
         | Ah K. It's like someone saw regexs and thought "I wish all
         | programming was as readable as this!"
        
         | speedgoose wrote:
         | Very impressive, I understand the first two lines of the file.
        
           | creddit wrote:
           | In context, I don't think I actually even understand the
           | second line.
        
         | [deleted]
        
       | dunefox wrote:
       | I'm torn between F# and Common Lisp (maybe even Raku for one or
       | two puzzles). Julia is my fallback, as always. I think this year
       | I want to solve all puzzles (got to 3/4 last year) and have all
       | of them run in under one second, collectively. A tall order but
       | interesting and fun!
        
         | dharmaturtle wrote:
         | If you do it in F#, try out VS notebooks:
         | https://www.compositional-it.com/news-blog/a-brief-introduct...
         | 
         | It makes working with the F# REPl very nice. I also had a good
         | experience with F# type providers on consuming external input
         | like AoC's.
        
         | na85 wrote:
         | I did Common Lisp last year. It was fun and often my solutions
         | were extremely short in terms of LOC, because of how expressive
         | Lisp is.
         | 
         | I got frustrated half way through because most of my time was
         | spent fighting parsing bugs, since AOC tends to give you the
         | data in very inconvenient formats.
        
           | zelphirkalt wrote:
           | For the parsing I used a PEG parsing module (of GNU Guile).
           | That made it really safe and precise, but also cost much more
           | time than fumbling around with regex. I am more comfortable
           | with my code being probably correct and for a work problem, I
           | would rather use a grammar and parser than some elaborate
           | regex mess in many cases. So I did the same in AoC. This
           | meant however, that I fell behind. Once that happened, I did
           | not continue for long. Coworkers also stopped a bit earlier.
           | Lets see how far I can go with solving this year's puzzles.
           | Hopefully I can share the joy of collecting stars with anyone
           | I know.
        
           | dunefox wrote:
           | Yeah, I did the first week of 2020 with both Lisp and Julia
           | and parsing was indeed an issue; but I'm a Lisp beginner
           | anyway.
           | 
           | Do you have a repo somewhere with the lisp code?
        
             | Jtsummers wrote:
             | I just scanned through my 2020 solutions. It seems I used
             | cl-ppcre for almost all my parsing if I couldn't read them
             | directly with the built-in read or read-line functions. On
             | the one occasion I used parseq in 2020 I didn't actually
             | need it (a regex would've done the trick, day 2 password
             | parsing). Parseq is a good option for anything more complex
             | than regexes, though. I'd suggest taking a few days worth
             | of puzzles and writing parsers to get some practice.
             | 
             | https://github.com/mrossini-ethz/parseq/
        
             | na85 wrote:
             | I'm afraid I don't have a repo, sorry. I was working via
             | several different machines and so I kept all the code on my
             | brother's server but he lost the disk encryption keys, kind
             | of a long story.
        
       | s0rr0wskill wrote:
       | I've heard of AoC but never participated in it before
       | 
       | How hard would it be for someone to finish the entire thing? I'm
       | planning to use this as an opportunity to learn Python. I have
       | some programming experience in Java, C, and JS but not that much.
        
         | keyle wrote:
         | The first 3 days are "easy". The following 5-10 get harder,
         | past the mid month, it takes serious commitment (unless you're
         | a wiz of course!).
         | 
         | Overall it is absolutely worth attempting, you'll learn
         | something guaranteed, about algorithms, about the language(s)
         | you chose and about yourself (resilience and determination).
        
         | mdwhatcott wrote:
         | Check out a few problems from a previous year to get a feel for
         | the difficulty. Generally, the puzzles get harder as the month
         | progresses. Here's last year's calendar:
         | https://adventofcode.com/2020
        
         | pietroppeter wrote:
         | It is a great opportunity to do that. I would say do not expect
         | to complete the year (most of us don't). My bet is you will
         | enjoy it anyway, even if you end up having a hard time (my
         | personal suggestion is to keep trying on new days even when you
         | did not complete previous ones)
        
         | bccdee wrote:
         | It's very doable, but the problems tend to get longer later in
         | December, so it's easy to fall behind late in the month. It's
         | fun, it's certainly worth giving a shot.
        
         | da39a3ee wrote:
         | It's doable if you (a) are good at algorithmic programming
         | challenges, (b) don't have a job, and (c) don't need to buy any
         | christmas presents.
        
           | smrq wrote:
           | You're _really_ overselling the time commitment, in my
           | opinion. Last year, only three days (13, 19, 20) took me more
           | than a half hour. I suppose I probably fit criterion A, but
           | the other two are nonsense.
        
             | da39a3ee wrote:
             | That's really impressive, congrats! But, I'm not a bad
             | programmer and up to around day 15 they regularly took me
             | multiple hours. And around day 15 I started to find them
             | hard as in couldn't do them. Do you remember what it's like
             | to not be able to do a problem? There are lots of normal
             | people reading HN -- surely you remember what they're like?
             | Like, imagine someone who's learning to program, or one of
             | those people who's really keen to do things in an obscure
             | abstract way, but hasn't yet learned how to do things
             | usimply. Have you met programmers from bootcamps who've
             | only been taught a jumble of javascript, mostly framework
             | stuff? I know there aren't many people like that where you
             | work! But they do exist and they are here with us reading
             | HN.
             | 
             | It often takes me 15 or 20 minutes to read and understand
             | the problem description. But it sounds like you frequently
             | had solutions written within that time!
        
               | pantulis wrote:
               | I'm more with you, I guess. I find the increasing
               | difficulty to push my brain more and more to its limits.
               | So I usually just do the first few days in my language of
               | choice for that year and there I go. No need to stress.
        
       | hanoz wrote:
       | The first Advent of Code since the advent of Copilot. Should be
       | interesting.
        
         | [deleted]
        
       | kryptiskt wrote:
       | Advent of Code is fun! I have done it every year since the start.
       | I have previously used C++, Rust, Racket, F# and a smattering of
       | Factor and SML.
       | 
       | I'm vacillating between doing it in C# and Javascript/Typescript
       | this year. C# has gotten more attractive lately as there are
       | improvement that makes it less ceremonious for short programs,
       | like toplevel statements and global imports, and also fun
       | optimizations for ricers. If I do it in JS/TS I would do it in a
       | web environment, and try to do it with a nice web GUI.
        
         | sp33der89 wrote:
         | You might like Scala 3 starting off quickly with:
         | https://scala-cli.virtuslab.org/ too (maybe!).
        
       | forrestthewoods wrote:
       | One of my favorite times of year!
       | 
       | A couple of years ago I used Advent of Code to learn Rust. This
       | year I'm going to use it to learn Zig.
        
         | tslater2006 wrote:
         | How was the experience for you? I've done the past few years in
         | C#, but am considering using 2021 to learn Rust.
        
           | forrestthewoods wrote:
           | A++++ loved it. I wrote a pair of blog posts about it.
           | 
           | https://www.forrestthewoods.com/blog/learning-rust-via-
           | adven... https://www.forrestthewoods.com/blog/solving-advent-
           | of-code-...
           | 
           | To be clear, I don't compete for the leaderboard or code
           | golf. But I do try to write elegant code that's performant.
           | 
           | AoC is a great way to learn a new language. I try to solve
           | the puzzles entirely on my own. Then I check the Reddit
           | solutions thread and Ctrl-F my language. It's a great way to
           | learn new tricks, libraries, or just idiomatic language
           | style.
           | 
           | And using Rust for AoC turned me into a certified fan. Rust
           | iterators are really great compared to C++. They're like C#
           | linq but better. The itertools crate is super helpful.
        
           | skavi wrote:
           | You can definitely get some incredibly elegant and fast
           | solutions using Rust. Check out timvisee's AoC 2020 [0]. It
           | honestly had a significant impact on my personal style.
           | 
           | [0]: https://github.com/timvisee/advent-of-code-2020
        
             | timvisee wrote:
             | Thanks for linking! I plan to do something like this again
             | this year :)
        
           | bccdee wrote:
           | I usually do it in Rust. I have a lot of fun with it, it's
           | great practice.
        
       | __mharrison__ wrote:
       | I recorded about 40 hours of me solving these problems from
       | scratch last year. That was not for everyone but some people
       | really like seeing your thinking process, getting stuck, going
       | down the wrong path, and recovering.
       | 
       | This year I'm going to be hosting a series of workshops to
       | discuss solutions in Python.
       | 
       | Participants will come to the workshop having already implemented
       | the problems we will be discussing. The goal will be learning
       | about more intermediate and advanced features, testing, OO vs
       | functional solutions, utilizing editors efficiently, getting
       | feedback, data structures and runtime, and improving your coding
       | ability.
        
       | mrtweetyhack wrote:
       | Fuck you Microsoft
        
       | jstx1 wrote:
       | The best thing about Advent of Code is how you can adjust it to
       | anyone's skills and interests - you can do it for time, you can
       | take ages, you can use any language you want or multiple
       | languages, you can get help from other people online, you can go
       | down various CS rabbit holes, you can make more elaborate
       | solutions and/or extensions (some people were doing really cool
       | visualisation of the game of life variations last year) etc.
       | 
       | It's very easy to recommend to it anyone who does any amount of
       | programming at any level, from complete beginners to very
       | experienced.
       | 
       | Other people in this thread are talking about learning new
       | languages and I found that a bit distracting. I think I'd rather
       | focus on the puzzles themselves and there's also something very
       | satisfying about writing a clean and concise solution in a few
       | lines which you can't always do when you're picking up a new
       | language. I like using Python for it because I can just translate
       | what I'm thinking to a solution without worrying about the
       | language itself. Also, even if I didn't mind doing it in a new
       | language, I don't think that AoC gives you large enough problems
       | that can really explore a new language and all of its features.
       | And you can always mix the languages if there's a language that's
       | really suitable for a given problem. You don't have to stick to
       | the same language for all problems.
       | 
       | I really enjoyed last year's, I'm looking forward to this one.
        
       | acheron wrote:
       | Did they remove the requirement to link an external account yet?
        
         | jweather wrote:
         | No, because they have leaderboards. You have your choice of
         | Google, Github, Twitter, or Reddit though. I don't believe
         | Reddit even requires an e-mail address to create an account.
        
       | jodrellblank wrote:
       | NB. there's an Advent of Code subreddit and every day has a
       | 'solutions' thread where people post their code in all kinds of
       | languages, and discussions of different approaches, which is
       | interesting to browse.
       | 
       | e.g. 2020 Day 1:
       | 
       | https://old.reddit.com/r/adventofcode/comments/k4e4lm/2020_d...
        
         | neogodless wrote:
         | What does NB mean?
        
           | fn-mote wrote:
           | "Note well" https://en.wikipedia.org/wiki/Nota_bene
        
           | auxym wrote:
           | Nota bene: https://en.wikipedia.org/wiki/Nota_bene
        
       | vletal wrote:
       | I almost got an heart attack while seeing this post. Still dizzy
       | from waking up early I thought it was already December.
        
       | skhm wrote:
       | I honestly can't wait for this to open. I ground out the full 300
       | stars recently going back through all the previous years and it
       | was one of my favourite programming experiences. Eric Wastl's
       | such a great problem setter.
        
       | gameswithgo wrote:
       | Good way to learn Rust, F#, Nim, Zig or Lisp! or anything but
       | those are all worth a look
        
         | fault1 wrote:
         | I will be doing it w/ Zig and Julia this year, i'm redoing some
         | Rust, python, and scala solutions from previous years
        
         | redrobein wrote:
         | Gonna be giving APL/J a shot this year.
        
           | bear8642 wrote:
           | Remember seeing someone did videos last year exploring APL
           | solutions.
           | 
           | Not sure if doing again, but could be useful resource
        
       | simongauld wrote:
       | Have gone back to 2019 day 10, warming myself up for this year.
       | Trying to get my colleagues to participate, too.
        
       | vavooom wrote:
       | Would people reccomend this as a way to cement an understanding
       | of Python / OOP in general? I'm typically more geared towards
       | data science style scripting use cases and want to explore more
       | problem focused programming.
        
         | WoahNoun wrote:
         | I usually use AoC with some specific goals or limitation in
         | mind to teach myself. The problems will not require OOP, but if
         | you force yourself to solve each problem using OOP...
         | 
         | Last year I did typescript and tried to really focus in on the
         | type system.
        
         | bashbjorn wrote:
         | I highly recommend it to explore new programming styles in
         | general. As some others, I use it as an excuse to learn a new
         | language each year.
         | 
         | While I think python is a really great language for advent of
         | code, I'm not sure I'd recommend going for an OOP-heavy style.
         | Although that might just be a matter of personal taste - I
         | think OOP is a poor strategy for most problems.
        
           | overlordalex wrote:
           | You can go one further - last year I tried to solve every
           | problem in a different language!
           | 
           | I first heard of people doing this for codejam, and it works
           | just as well for AoC
           | 
           | My 2c from the experience,
           | 
           | * I hated Go for this style of programming, but I could see
           | it being good for some production-ready code
           | 
           | * Rust should be renamed to Rustcargo. Even for the most
           | basic of tasks it seems like these two are welded together.
           | 
           | * I still really like Nim as a replacement for Python in my
           | toolbox
        
             | forrestthewoods wrote:
             | > Rust should be renamed to Rustcargo
             | 
             | I much prefer RustCargo to
             | C++BringYourOwnShittyBuildSystem! Cargo definitely one of
             | the bright spots in Rust imho.
        
           | wpietri wrote:
           | I like OOP approaches a fair bit, but only for relatively
           | large, long-lived systems, especially when working with a
           | team. E.g., the Domain-Driven Design approach can provide a
           | ton of shared clarity.
           | 
           | For something like Advent of Code, though, I'd avoid it. It's
           | just me and it's not for long; there's no need for me to be
           | explicit about how I'm thinking about the problem.
        
           | heelix wrote:
           | Yup. Very much a chance to learn a new (for me) language.
           | Looking to do Golang this year - brushing up on the basics of
           | the language as we roll into a long turkey weekend.
        
             | BeFlatXIII wrote:
             | I'm torn between Clojure (totally n00b) or Elixir (mostly
             | to force myself to use it rather than defaulting to Python)
        
               | nanomonkey wrote:
               | This year I'm going to try it with Babashka, the native
               | Clojure scripting runtime. See how far it can take me.
        
               | ravi-delia wrote:
               | I'm something of an elixir zealot, but I have to say that
               | Clojure has the most pleasurable syntax for this kind of
               | thing out of any programming language.
        
               | b5n wrote:
               | Being an elixir zealot have you ever considered lisp
               | flavored erlang? If so, what are your thoughts in
               | comparing it to clojure?
               | 
               | https://lfe.io/
        
               | BeFlatXIII wrote:
               | That's good to know. What is it about the AoC that makes
               | it play into Clojure syntax so well?
        
               | hiepph wrote:
               | Clojure is fun to try out. I tried it last year and had a
               | lot of fun combining and finding the _right_ function
               | from its huge expressive vocabulary. It inspires you to
               | treat code as data.
        
               | BeFlatXIII wrote:
               | I've had a couple of Clojure books I've meant to work
               | through over the past year. Where I'd get stuck is in the
               | development workflow more so than in the language
               | features or syntax. Clojure (and lisp-like languages in
               | general) seem like my usual edit, save, run loop isn't
               | the most effective way (especially if it's Clojure and
               | the JVM needs to start each time if you run cold).
        
         | rak1507 wrote:
         | Python, sure, but not OOP. Most solutions will not be very
         | large and there's really no need for OOP (ever) but
         | particularly not for something like this.
        
           | exdsq wrote:
           | Don't hate on poor old OOP :( It's a good way to take that
           | step from scripting to software engineering. Sure it can get
           | out of hand with AbstractSingletonProxyFactoryBean's but so
           | can other paradigms.
        
             | lostcolony wrote:
             | I mean...it forces you to plan and organize your code, if
             | that's what you mean. But I also think it encourages you to
             | do it in a way such that the organization becomes more
             | important (and oftentimes, more complicated) than the
             | problem you're solving, and I'd contend that's kind of a
             | bad way to take that step, especially for people not
             | otherwise experienced enough to know how to avoid that
             | complexity.
        
           | benttoothpaste wrote:
           | You can apply OOP principles to even the simplest problems.
           | Search for "fizzbuzz enterprise edition" to get some ideas.
        
         | exsf0859 wrote:
         | AoC won't teach you anything about OOP.
         | 
         | The problems are designed to be solved in Python with less than
         | 100 lines of code, by taking advantage of Python's extensive
         | library of data structures and algorithms.
        
           | lpapez wrote:
           | I did AoC2020 with C++ and did it in a enterprise, over-the-
           | top, well-structured way. E.g. need to find two items whose
           | prices sum up to 123? Implement a multidimensional knapsack
           | just in case you need it later (spoiler: I did need it). If
           | you take the time, and don't bother with the leaderboard, you
           | might find AoC to be a really fun and engaging way to explore
           | new concepts and solutions.
        
             | gordaco wrote:
             | Yes, this is the way I do it as well. There were quite a
             | few cases where I went all in with an apparently
             | overengineered solution, and then I could use the code
             | directly for the second problem with almost no changes.
             | 
             | I don't go for being the fastest or anything, I just want
             | to do everything in a way that I like. Last year I did
             | everything on the same day it got out; I plan to do the
             | same this one, unless there is a particularly bullshitty
             | problem that puts me off.
        
           | Barrin92 wrote:
           | quite strongly disagree with this. You _can_ solve the
           | problems with fewer than 100 lines of code, but you can
           | certainly also take it as an opportunity to flesh your
           | programs out in OOP style. In general, programming is about
           | what you want to do and learn, and the problems aren 't
           | designed for any specific paradigm. A lot of people have
           | taken Advent of Code as an opportunity to not lean on any
           | external libraries for example.
           | 
           | There's numerous problems from board or combat game
           | simulations, to mazes and the intcode computers that lend
           | themselves to be approached in OOP style. The context OP is
           | coming from is data science scripting, it's fine to start
           | with small examples.
        
         | heavyset_go wrote:
         | I think most problems would be solved elegantly with a pseudo-
         | functional approach in Python, so AoC wouldn't be the best for
         | OOP.
         | 
         | Make an API client, a GUI or game if you want to use OO in
         | Python canonically.
        
           | nulbyte wrote:
           | Maybe they could be, but that doesn't mean they have to be.
           | My intcode computer was written using OOP.
        
         | lalaland1125 wrote:
         | Advent of Code is generally to small to help with OOP practice.
         | It will help get you familiar with Python though.
        
         | grumple wrote:
         | Contrary to other responses, you can certainly use OOP
         | programming to solve these problems, and I think that is a
         | better way to do it. You wouldn't write 100 line blocks of
         | dense algorithms in prod code, why do it here? Thinking about
         | breaking things into objects makes a lot of the problems easier
         | to solve in my opinion.
         | 
         | That said, I don't think it's great for really getting in depth
         | understanding of any language in particular - you'll only use a
         | limited subset of language features for these problems.
        
         | gramie wrote:
         | A couple of years ago I decided to learn Kotlin by doing AoC
         | puzzles. It was a really good way to get comfortable with the
         | basic syntax and data structures of the language.
        
         | weaksauce wrote:
         | Doubtful unless you do it in a way that facilitates that
         | understanding. it could be like a year or two ago where you
         | build up a computer from the ground up and do things with it
         | where it would be more oop but a lot of the times they are self
         | contained and don't require that much structure.
         | 
         | if you do it deliberately it's a good way to learn a new
         | language.
        
         | bccdee wrote:
         | OOP's toolset is useful for abstracting over interchangeable
         | parts, which is the sort of thing that doesn't really come up a
         | lot in Advent of Code problems. AoC is lots of fun, and Python
         | is a great language to do it in, but I don't think it's a good
         | place for OOP.
        
         | gameswithgo wrote:
         | it can be a great way to learn a language and to explore other
         | programming paradigms.
        
         | dr_kiszonka wrote:
         | I'd say AoC is more about problem solving and less about
         | Python. The puzzles tend to be pretty good and I usually learn
         | something from them. You could have a look at the previous
         | edition to see if AoC is something you'd enjoy [0]. What I
         | found informative was looking up other people's solutions on
         | reddit and GitHub.
         | 
         | There is also Rosalind for more data oriented challenges [1].
         | 
         | 0. https://adventofcode.com/2020
         | 
         | 1. http://rosalind.info/problems/locations/
        
           | nijaru wrote:
           | I just started rosalind after someone posted it on here last
           | week. They're definitely focused on bioinformatics similar to
           | euler being more math focused.
           | 
           | I haven't gotten too far, but the initial problems don't seem
           | too hard in higher level languages. They are very good
           | problems to get better at IO, string manipulation, and data
           | wrangling in your language of choice though.
        
             | sundarurfriend wrote:
             | > I just started rosalind after someone posted it on here
             | last week.
             | 
             | Same.
             | 
             | > I haven't gotten too far, but the initial problems don't
             | seem too hard in higher level languages.
             | 
             | True. But the info boxes in the top are interesting and
             | informative, those make it worth it to keep going.
             | 
             | > They are very good problems to get better at IO, string
             | manipulation, and data wrangling in your language of choice
             | though.
             | 
             | For me, it's also a way to peek into BioJulia and get some
             | familiarity with it. (I don't mind "cheating" this way
             | since this was my primary goal with the site anyway.) So
             | far I'm pretty impressed by how fast it is!
        
       | lpcvoid wrote:
       | From the FAQ:
       | 
       | >I have a puzzle idea! Can I send it to you?
       | 
       | >Please don't. Because of legal issues like copyright and
       | attribution, I don't accept puzzle ideas, and I won't even read
       | your email if it looks like one just in case I use parts of it by
       | accident.
       | 
       | It's sad that we live in a world where code snippets sent by
       | others can result in legal issues down the line.
        
         | aloisdg wrote:
         | Let's create an Advent of Community with crowd source puzzle
         | under FOSS license
        
           | lghh wrote:
           | This is a neat idea. If you're serious, I'd be willing to
           | provide my email and chat through the idea and help out.
        
           | Buttons840 wrote:
           | There's a Reddit that has a coding problem every day.
        
       | jypepin wrote:
       | I hope that Peter Norvig participates this year again!
        
         | mdwhatcott wrote:
         | I likewise hope for Michael Fogleman's participation:
         | https://github.com/fogleman?tab=repositories&q=advent
        
       | nemo1618 wrote:
       | I've done AoC in Go every year, with a few good leaderboard
       | placings, but this year I'm trying something new: a _custom
       | competitive programming language_ , optimized for solving AoC
       | problems as quickly as possible. Will it be powerful enough to
       | solve all of the problems? Certainly not. But hopefully, on the
       | problems it _can_ solve, it will enable me to solve them much
       | faster than Go would. :)
        
         | jb1991 wrote:
         | What's custom about Python? ;)
        
         | fullstackchris wrote:
         | I'll be doing the opposite, trying to do it in Go for the first
         | time - it's a language I've been wanting to learn. Probably a
         | bad decision to do the challenges with the overhead of learning
         | Go at the same time, but it'll still be fun :)
         | 
         | It's at least good to hear that Go is a competetive option!
        
           | nemo1618 wrote:
           | Good luck! I recommend building up a library of helper
           | functions; it will save you a lot of typing. Here's mine: htt
           | ps://github.com/lukechampine/advent/blob/master/utils/uti...
        
           | i_hate_pigeons wrote:
           | I'm doing the 2020 ones in go as practice, it's been easier
           | to learn than I was expecting
        
       | tofflos wrote:
       | How hard is it to go all the way? Last year 163763 people
       | completed both puzzles for day 1. On day 25 only 13016 completed
       | both puzzles resulting in a "completion ratio" of 13016 / 163763
       | = 7.95%.                      Day 1  Day 25 Ratio       2020
       | 163763 13016   7.95%       2019 103187 3399    3.29%       2018
       | 71480  3192    4.47%       2017 48543  5577   11.49%       2016
       | 19299  2772   14.36%       2015 55970  4171    7.45%
       | 
       | Based on https://adventofcode.com/2020/stats,
       | https://adventofcode.com/2019/stats,
       | https://adventofcode.com/2018/stats,
       | https://adventofcode.com/2017/stats,
       | https://adventofcode.com/2016/stats and
       | https://adventofcode.com/2015/stats.
        
         | netcraft wrote:
         | In my experience the difficulty and time requirements ramp up
         | considerably after about day 10. I think that plus the fact
         | that its Christmas time makes it hard to complete the whole
         | thing - I would even wager that some significant fraction of
         | the people who completed day 25 didnt do it in December...
        
       | bogdanoff_2 wrote:
       | How does this compare to "classical" competitive programming
       | (like ICPC, Codeforces, etc)?
        
       | iofiiiiiiiii wrote:
       | What exactly is it? I understand there is something about code
       | puzzles but how does it work? How does the leaderboard work -
       | presumably there is some sort of scoring involved?
        
         | uyt wrote:
         | Daily two part puzzles, for one star each, 50 stars total.
         | Second part is usually related to the first (but unknown until
         | you solve the first) which makes you refactor or learn to write
         | your code generically the first time. Input is usually a small
         | text file. Puzzles are often dependent on earlier ones
         | (spoilers: most years you write a interpreter for a made up
         | language over a few days and later puzzles use it as an input
         | generator which you seed with the text file)
         | 
         | Leaderboard points are only assigned if you're in the top 100
         | for either parts which you should ignore if this is your first
         | time since it's not the point!
        
         | [deleted]
        
         | jdrek1 wrote:
         | You get points for being the fastest to submit the correct
         | solution to a puzzle part each day. First one gets 100 points,
         | second one 99, and so on down to place 100. So you could get up
         | to 200 points per day if you solve both parts of the puzzle as
         | first one. However unless you can be on your computer when the
         | puzzles unlock (midnight EST (UTC-5)) I wouldn't bother with
         | the global leaderboard, it gets filled within minutes.
        
       | xyproto wrote:
       | Time to learn Zig!
        
         | sagarm wrote:
         | Tried to learn Zig by doing AOC earlier this year. Wow, that
         | was painful. Python is a much better match for all the text
         | manipulation.
        
       | Angostura wrote:
       | Time to break out the ZX Spectrum Basic again!
        
       | mikewarot wrote:
       | I've still got my Lazarus/Free Pascal installation warmed up from
       | Google Kickstart, so I'm ready.
        
       | polytely wrote:
       | I love advent of code, but I always burn out on it after a couple
       | of days because it just starts taking up too much time. I'm
       | always amazed at the people here that complete the whole thing, I
       | feel like there must be a vast gulf in skill level between me and
       | the average hn poster. Excited to try the first couple of days
       | again this year.
        
         | [deleted]
        
         | it_does_follow wrote:
         | > there must be a vast gulf in skill level between me and the
         | average hn poster
         | 
         | I suspect it's much more a time gulf than a skill gulf.
         | 
         | I love AoC as well and don't so much burn out but find that
         | after a week of coding for fun in the evening a mountain of
         | real world responsibilities start piling up, especially around
         | the holiday season.
         | 
         | When I was in undergrad I had virtually no family
         | responsibilities during December and a large amount of free
         | time when classes ended, so it would have been easy to spend
         | hours a day on AoC. Many younger, single professionals are
         | likely in the same situation.
         | 
         | I think for most adults with family responsibilities and full
         | time jobs (and likely a range of side projects that also need
         | attention) that first week of December is a rare lull, and a
         | great time to solve a bunch of fun code problems. After that
         | more and more other things take focus as the holidays approach.
        
       | keyle wrote:
       | The scoring should adjust based on your chosen language of choice
       | and mental demise ;)
       | 
       | I look forward to it!
        
       | pxx wrote:
       | It was only so long ago somebody asked "[Whatever happened to
       | Wolfram Alpha](https://news.ycombinator.com/item?id=29131931)".
       | As somebody who didn't have Mathematica installed at the time,
       | cheesing a problem with Wolfram Alpha was for sure one of the
       | best applications I've had with it.
       | 
       | this year I guess I should probably have mathematica installed
        
         | freemint wrote:
         | If you just want access to the language and are fine with
         | Jupyter as a front end you can just use
         | https://www.wolfram.com/engine/ no need to buy anything then.
        
         | FPGAhacker wrote:
         | Why bother installing Mathematica? You get all the
         | functionality for free in their cloud notebooks.
        
         | NoblySP wrote:
         | In what way did you cheese the problem?
        
       | beached_whale wrote:
       | It's a trap... :) This site is the biggest nerd snipe
       | https://xkcd.com/356/
       | 
       | Love it and excited for 2021
        
       | aero-glide2 wrote:
       | Had fun doing it with /sci/ in 2019. Hoping to complete this and
       | the first 100 problems in project Euler!
        
       | david2ndaccount wrote:
       | I'll probably end up doing it in C again.
        
       | steinuil wrote:
       | I should probably finish last year's. I did all parts mostly in
       | time except for day 20, I couldn't figure out part 2 and just
       | refused to do it.
        
         | jstx1 wrote:
         | Day 20 last year was definitely the most time-consuming and
         | longest solution. If I remember correctly, the inputs for that
         | day have a guarantee that's not mentioned in the instructions,
         | so you can just write a naive brute-force-ish solution and get
         | the answer in a reasonable running time.
        
       | jstanley wrote:
       | I love Advent of Code. If you like programming, Advent of Code
       | probably has something for you. It's a great source of practice
       | problems for learning a new language or style. There's a
       | "competitive" aspect for people who like programming
       | competitions, and you can even make private leaderboards so you
       | can compete against your friends even if you can't make it on to
       | the global leaderboard.
       | 
       | Last year I was earnestly trying to compete on the global
       | leaderboard, and scored points a few times, ending up 103rd
       | overall (slightly frustrating as the displayed leaderboard only
       | goes down to 100th place!), but it's too stressful for me to want
       | to do that again, and in my timezone it requires getting awake in
       | time for the puzzles to be released at 5am.
       | 
       | This year I've been building a homebrew 16-bit CPU from 74xx
       | logic, and have written an operating system and development
       | environment for it, and I plan to do as much as possible of
       | Advent of Code 2021 on my homemade computer.
       | 
       | There are 2 big hurdles to this. The first is that my computer is
       | very slow. It takes over a minute to compile a typical program,
       | which makes for a very long edit-compile-test cycle, and I don't
       | have any hardware multiplication etc., so even integer arithmetic
       | can be quite expensive.
       | 
       | The other hurdle is that it only has 64K words of memory, and
       | IIRC some Advent of Code problems in the past have required
       | keeping track of state for dozens of thousands of separate
       | things. In those cases I'd either fail, or come up with a way to
       | use the disk for extra storage. I look forward to trying,
       | regardless.
       | 
       | As it happens, just this morning I did kind of a "dry run" on
       | problem 1 from 2016 on my homemade computer, and recorded my
       | attempt, which you can watch if you want:
       | https://www.youtube.com/watch?v=UOizI9qi6FU
        
         | templeosenjoyer wrote:
         | Unrelated but your automated chess board[1] is wonderful. Good
         | work!
         | 
         | [1] https://www.youtube.com/watch?v=8ScFtkWvHW8
        
         | scoot wrote:
         | Do you have more info on your processor build? Sounds
         | fascinating! I hoped that there might be a video on your
         | channel, but it didn't appear so.
        
           | jstanley wrote:
           | I don't have a great single resource unfortunately. I'd like
           | to put up a web page about it at some point.
           | 
           | This is the github repo that contains everything:
           | https://github.com/jes/scamp-cpu/ - some of the stuff under
           | "doc/" might be what you're after (but some of it is just
           | incoherent ramblings).
           | 
           | I have some blog posts here:
           | https://incoherency.co.uk/blog/tags/cpu.html
           | 
           | And there is a video here, but it's not really very
           | informative: https://www.youtube.com/watch?v=4sBB0iD6XvI
        
         | dpflug wrote:
         | Building a Forth could tighter your edit-test cycle.
        
           | jstanley wrote:
           | I am fascinated by Forth, but every time I've tried to learn
           | it I haven't really "got it". It's always felt very unwieldy
           | to me.
           | 
           | But implementing Forth on my CPU, and getting proficient at
           | using it, is definitely something I'd like to do at some
           | point!
        
             | bdowling wrote:
             | > I am fascinated by Forth, but every time I've tried to
             | learn it I haven't really "got it".
             | 
             | Try reading Jonesforth, a literate Forth implementation in
             | one x86 assembly file and one Forth file. You can read it
             | top to bottom and it will explain how everything works
             | step-by-step.
             | 
             | https://rwmj.wordpress.com/2010/08/07/jonesforth-git-
             | reposit...
             | 
             | Github mirror: https://github.com/nornagon/jonesforth
        
             | thoughtFrame wrote:
             | I don't know if I'm not creative enough but what I've read
             | about Forth tells you about the stack, about how to make
             | new words, push arguments and pop to print. But that's it,
             | and I can't figure out how to get things done with those
             | building blocks. There's the famous washing machine example
             | but there's not much else about doing things with it.
             | 
             | It's something that many programming language tutorials
             | miss: exploring the possibility space and teaching you the
             | language's expressive power
        
               | Jtsummers wrote:
               | Starting Forth: https://www.forth.com/starting-forth/
               | 
               | Thinking Forth: http://thinking-forth.sourceforge.net/
               | 
               | In combination, very effective introduction to
               | programming in Forth including how to go about combining
               | those building blocks.
        
         | rak1507 wrote:
         | This is seriously cool. Nice one.
        
       ___________________________________________________________________
       (page generated 2021-11-21 23:01 UTC)