top | item 21674752

Advent of Code 2019

552 points| scottdw | 6 years ago |adventofcode.com | reply

122 comments

order
[+] aquova|6 years ago|reply
Many of the comments are about the event as a whole, but I'd like to commend the author for the day 1 puzzle, which I think is very cleverly written. Many people (including myself) use these as an opportunity to try out learning a new language, and the first puzzle does a good job of making sure you know enough basic operations for some of the puzzles coming up. The puzzle itself wasn't very difficult, you could do it by hand if you really wanted to, but it required you to know how to read and parse lines in a file, handle compound data structures, iterate through, and perform basic operations (floor, casting strings to ints, etc). I thought it was really well done, and creates the basic knowledge for the puzzles ahead.
[+] znpy|6 years ago|reply
> Many people (including myself) use these as an opportunity to try out learning a new language

I hadn't thought about that! I'll take this as an opportunity to learn Rust!

[+] melling|6 years ago|reply
Learning new environments can be painful so it’s good it starts off easy.

I’m trying to solve them with Swift Playgrounds on the iPad, for example. And I can’t figure out how to create a simple text file for the data.

[+] zeveb|6 years ago|reply
> The puzzle itself wasn't very difficult, you could do it by hand if you really wanted to, but it required you to know how to read and parse lines in a file, handle compound data structures, iterate through, and perform basic operations (floor, casting strings to ints, etc).

I don't believe that it required any compound data structures, just looping through the lines in the file.

You're right about the rest, though.

[+] ahaferburg|6 years ago|reply
It's faster to just paste the input into your favorite editor, and massage it gently until it is a literal in the language you're using. No parsing necessary.
[+] rb808|6 years ago|reply
lol I actually did this typing into source comma down comma down comma... Only after reading this I realized how lazy I was so went back to do it properly. :)
[+] messe|6 years ago|reply
Self promotion, but as this is my first year doing advent of code I'm solving all of the problems using awk[1], the solutions will be published here[2]

[1]: https://man.openbsd.org/awk

[2]: https://jo.ie/advent-of-awk-2019.html

[+] nabraham|6 years ago|reply
Eric, the author, says he won't accept any puzzle submissions because of attribution and legal issues. This seems like the wrong outcome for people who want to make the site better but don't want credit, compensation, or attribution.

Has anyone seen a site using an IP assignment agreement which is the equivalent of "take my work, I don't want credit, and it's just for your site"?

The Creative Commons CC0 license comes closest, but one could scrape those puzzles and create a competing site, which I'd guess Eric wants to avoid.

[+] tl|6 years ago|reply
It’s a preference in his case that cannot be solved with licensing. Eric doesn’t want even potential ideas to influence him, and he says he has more puzzle ideas than time to implement them.

Personally, I suspect that he wants something that consumes so much of his free time to wholly be his, and I respect that.

[+] arve0|6 years ago|reply
The problem is trusting the submitter. How do you make sure derivate work is not submitted?
[+] ahaferburg|6 years ago|reply
If you want to help, why not ask the people running the site what you can do to help? Do you actually want to help, or do you want to make puzzles? Or do you just want to discuss a perceived problem that may or may not exist?
[+] inerte|6 years ago|reply
“your site” is really complicated. Who is “you”, person, website or the company? If it’s the person can they transfer the rights? What happens if they die? If they donate the estate? If they get hired or contracted? If the website expands scope or changes in any way?
[+] mjtlittle|6 years ago|reply
Maybe he enjoys/benefits from the work, I feel like coming up with puzzle ideas would be somewhat fun/beneficial. I would definitely assume that if this were not the case he would outsource it or maybe even open source it.
[+] thethirdone|6 years ago|reply
I was doing a little of catching up on older problems to improve my speed to get on the leaderboard and I found that the fastest way to finish one problem was to use oeis.

After seeing the problem [0], I didn't immediately think to use oeis because the manhatten distance of a spiral is pretty easy to code or do by hand. The second stage has a harder sequence though. It prompted me to check oeis and I easily got the answer [2] within a minute of checking.

Looking back at the first stage, I found a sequence for it [1] and PARI/GP code i could run to answer the question. If I had used oeis immediately I would have a solution to both phases in 2 minutes which would be the fastest on the old leaderboard for the problem [3].

[0]:https://adventofcode.com/2017/day/3

[1]:https://oeis.org/A214526

[2]:https://oeis.org/A141481

[3]:https://adventofcode.com/2017/leaderboard/day/3

[+] loeg|6 years ago|reply
I had plenty of 20-20 hindsight about faster ways to have solved puzzles in the past. I don't know if I was ever #1 on any day on either star. I think I might've been top 10, on one star, of one day, once.
[+] forrestthewoods|6 years ago|reply
Last year was my first year and I loved every second of it.

I strongly recommend using AoC as a tool to help learn a new language. Many people, myself included, use it to learn Rust.

The best part about AoC is the community. Everyone is super helpful and kind. The daily Reddit thread has solutions in every language under the sun.

My better half is a designer and is going to participate this year to help learn JavaScript.

[+] dom96|6 years ago|reply
This event is a really nice way to try out new programming languages. You can easily find many people doing the challenges in various languages and communities coming together to work through the problems together. It’s also very interesting seeing how each person solves the problem in their favourite language.

For example, here is the Nim communities effort: https://forum.nim-lang.org/t/5588

[+] Barrin92|6 years ago|reply
Always enjoy doing these but there was one last year that nearly broke me. I think it was day15. It was the worst combination of mind-numbing coding and horribly hard to debug special cases. It was purely convoluted with very little to think about which makes for the worst kind of puzzles
[+] cjauvin|6 years ago|reply
I can totally relate about that particular one, I remember that it destroyed a good part of a weekend for me, and I wrote that about it on Twitter, back in January of this year:

"I have thought about the particular challenges of this year's Advent of Code (which I greatly enjoyed once again, with some intermittent mixed feelings), and my conclusion is that some problems might very well be of similar difficulty levels, but with nevertheless very dissimilar frustration-inducing levels. And I think the frustration level is strongly correlated with the feedback signal one can use to debug. Case in point: Day 15, which was almost impossible to debug, once you had a working solution, versus Day 17, which was actually fun to debug, since the visual signal you could use was so strong."

[+] m000|6 years ago|reply
I strongly disliked the puzzles that quickly devolved to correctly handling a ton of corner cases. 15 and 17 were both in this category. What's the fun in that? This is like the boring part of being a developer. Without the payment that goes with being a developer.
[+] AdeptusAquinas|6 years ago|reply
That one wiped me out for a week too, and caused borderline psychological problems.

Ultimately though I realised that if I followed the description word by word, and made no assumptions, then I got the right solution. Still, a nightmare: you could pass all the examples, or even some alternate real sample data, and still get it wrong if you got the ordering slightly incorrect.

[+] m1kal|6 years ago|reply
Day 15 took me about 8 months, but I finally discovered I had made one wrong assumption that corrupted my solution for special cases...
[+] mathw|6 years ago|reply
I hit day 15 and stopped last year. There always seems to be one puzzle which is so irritating it no longer seems worthwhile when I could be playing some music or building something in Minecraft or just lazing around on the sofa with the cat.
[+] wycy|6 years ago|reply
Day 15 was terrible for me too. The edge condition I missed was that you could both move and attack in a single turn. It only changed the outcome for me in part 2. I was only able to finally debug it by comparing debug outputs every step with a known-good solution.
[+] sunaden|6 years ago|reply
If someone is interested in the previous years of Advent of Code they are available as notebooks in Peter Norvig's pytudes repository: https://github.com/norvig/pytudes
[+] narimiran|6 years ago|reply
Thank you very much for this!

I was aware of Norvig's 2016 AoC solutions, but I thought he never did any of the newer editions. I know what I'll be reading today :)

[+] qznc|6 years ago|reply
I'm trying to use J and still struggle with the second part of day 1. Any other J users?
[+] JaumeGreen|6 years ago|reply
I have found a solution someone posted [0]

It looks similar to what I though I had to write, but I will have to reread it and the documentation to understand it well.

And day 2 seems a bit too complex with my meager J knowledge. OTOH with the J interpreter for android and its terseness it seems the most suited language for programming on a phone, so I will probably stick to it.

[0] https://www.reddit.com/r/adventofcode/comments/e4axxe/2019_d...

[+] jammygit|6 years ago|reply
These are daily programming puzzles? How long do they take on average?

Also, I know somebody who is just starting out at coding. Would it be too hard for them? They are brand new, learning about loops

[+] teraflop|6 years ago|reply
I completed the whole thing last year; the problems start out very easy, but get dramatically more challenging over the course of the month. Check out the statistics for how many people completed each problem in 2018: https://adventofcode.com/2018/stats

The first few problems are approachable by pretty much anyone who understands how to do arithmetic, file I/O and basic flow control. Many of the later problems require advanced skills such as more sophisticated algorithms (graph theory, dynamic programming, etc.), reverse engineering, and careful debugging.

For what it's worth, I would expect anyone who knows what a loop is to be able to get the first half of today's problem without much difficulty. The second half is a bit less trivial but also pretty easy to understand.

[+] loeg|6 years ago|reply
If you're medium fast, they start out in the single digit or tens of minutes range and ramp up to some 60+ minute puzzles the last handful of days (but also some 20 minute puzzles, it varies a lot).

I haven't done it since 2017, and I was pretty quick (made that year's overall leaderboard), but on average they took me about 23 minutes (for both parts).

[+] Arnavion|6 years ago|reply
In general the puzzles involve basic operations that any language would have. Functions, data structures, recursion, some amount of back-and-forth between strings and numbers and records. There isn't any reliance on library-like things like making HTTP requests or parsing complex file formats. I think they would be fine for someone starting out at coding.

Every day's puzzle has two parts. The first part is usually easy. The second part is then a twist that requires a change to the solution of the first part.

Apart from that, you can always skip a day if you just can't solve it. The exception is that sometimes a puzzle can reference the solution of an older day, so if you'd solved the older day you would already have an understanding of how to proceed, and might be able to reuse some code.

[+] IbyvzOneoneh|6 years ago|reply
They take <15min - >2h

First couple of tasks are really easy, but difficulty increases over time and so does time needed to solve them.

Someone who is currently learning about loops might not be able to solve these on their own, but with someone else's help they might learn lots of useful concepts (e.g. linked lists, bfs, basic asm, how to code efficiently...) and try to apply them.

AoC are solving usually those who are quite familiar with programming and want to learn a new language or to compete with colleagues.

[+] j1elo|6 years ago|reply
I wondered the same, also thinking about people I know who are starting to program.

In the end I think it's not a good fit, given that basic concepts are still being understood, and the mere task of reading a file and iterating over the lines, even the concept itself of what "iterating" is, is already a big challenge...

Trying is free and won't hurt, though, so why not :)

[+] sergiotapia|6 years ago|reply
For someone just starting out they would get stuck on this very first problem, it involves recursion. People 'get' recursion, but coding it is something different.
[+] donatj|6 years ago|reply
I always have a ton of fun with these sorts of things. I always wonder how they come up with these sorts of puzzles. That's not a skill I have.
[+] Kinrany|6 years ago|reply
The third puzzle mentions Halt and Catch Fire, a brilliant TV show about innovation and the lives of the (fictional) people behind it.
[+] sircastor|6 years ago|reply
I went to bed before trying it last night, but couldn't sleep. So I did the day one problem early this morning. It was fun, and went quicker than I thought. I guess I must've improved from last year.
[+] LandR|6 years ago|reply
Day 2 part 2, what is it actually asking?

I can't tell from the description what the actual puzzle is...

Is it that I need to generate a program that generates the output 19690720 when run through the function that was written in part 1?