Advent of Code 2023 is nigh

by i13eon 12/1/2023, 4:50 AMwith 303 comments

by gh123manon 12/1/2023, 7:20 PM

I 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

by shever73on 12/1/2023, 4:05 PM

As 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.

by Chobileton 12/1/2023, 4:42 PM

Without 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.

by bradley13on 12/1/2023, 4:11 PM

Seems 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.

by MandieDon 12/1/2023, 1:48 PM

A bit off-topic, but does anyone know if Hanukkah of Data[0] is happening again this year?

[0] https://hanukkah.bluebird.sh/about/

by Foivoson 12/1/2023, 6:39 PM

The 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

by 63on 12/1/2023, 3:39 PM

Day 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.

by CobrastanJorjion 12/1/2023, 6:54 PM

Advent 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.

by matjazdrolcon 12/1/2023, 7:03 PM

I 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/...

by aaaronicon 12/1/2023, 4:17 PM

I 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.

by dataengineer56on 12/1/2023, 1:34 PM

It'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?

by kifon 12/1/2023, 5:15 PM

I 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.

by mikewaroton 12/2/2023, 7:00 AM

In 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

[2] https://github.com/mikewarot/Bitgrid

[3] https://github.com/mikewarot/Advent_of_Code_in_BitGrid

by Waterluvianon 12/1/2023, 2:09 PM

Every 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.

by kristapson 12/1/2023, 1:41 PM

Last 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

by ttrrooppeerron 12/1/2023, 2:20 PM

I will be doing this advent challenge this year instead: https://adventofchess.com/

Looking forward to read your write-ups!

by bryancoxwellon 12/1/2023, 2:08 PM

I 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?

by ni507on 12/1/2023, 6:59 PM

As 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/

by greymalikon 12/1/2023, 2:39 PM

I'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.

by anonyfoxon 12/1/2023, 1:28 PM

This 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!

by codr7on 12/1/2023, 7:00 PM

Most 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.

by laweijfmvoon 12/1/2023, 4:23 PM

> failed to authenticate. (access_token request returned 429 Too Many Requests)

Hope it's just a temporary issue!

by calibason 12/1/2023, 6:21 PM

Part 2 seemed fairly easy until I noticed "twone".

I used Rust and match_indices to get the answer.

by deafpolygonon 12/1/2023, 10:34 PM

I 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...

by rrishion 12/1/2023, 3:35 PM

Genuinely curios why people are so into AoC ... Feels leetcode-y

by Tainnoron 12/1/2023, 5:42 PM

Day 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.

by subseton 12/2/2023, 3:40 AM

First 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")])

by ohnoerikon 12/1/2023, 5:32 PM

I'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.

by AdamH12113on 12/1/2023, 5:17 PM

Advice 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.

by imperialdriveon 12/1/2023, 5:39 PM

Gosh 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.

by artzmeisteron 12/1/2023, 1:41 PM

common lispers unite

by usgroupon 12/1/2023, 9:00 PM

A Prolog Definite Clause Grammar (DCG) solution:

https://github.com/emiruz/adventofcode2023/blob/main/day01/p...

by cannabis_samon 12/1/2023, 7:26 PM

Man, 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…)

by NooneAtAll3on 12/1/2023, 2:13 PM

my 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

by drewcooon 12/1/2023, 11:24 PM

"Nigh" is off by at least one, depending when this is all read.

by w0mon 12/1/2023, 1:23 PM

yay

by berkeson 12/1/2023, 2:01 PM

Part 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.

by zehaevaon 12/1/2023, 2:09 PM

Another year and another Advent of Code that I don't have enough time in my life to do.

One year I'll actually finish!

by brightballon 12/1/2023, 2:14 PM

Shameless 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...

by rschiavoneon 12/1/2023, 1:45 PM

Opening up a tab to quickly solve the problem with ChatGPT in order to climb the leaderboard is the modern Tragedy of the Commons.

by sertbdfgbnfgsdon 12/1/2023, 5:01 PM

Maybe 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?

by nikolayon 12/1/2023, 5:05 PM

Python should be excluded! I force myself to use Go, but it's just not competitive.

by stirayon 12/1/2023, 1:44 PM

I 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)