Live data from Hacker News

Advent of Code 2023 is nigh

adventofcode.com

231–240 of 319 posts

Re: Advent of Code 2023 is nigh

#232
post #131
post #12

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_sha2…

I agree that using an auth provider is unnecessary for the problem faced. A bit ironic considering how AoC is all about programming challenges. Funny seeing the problem solved in 4 lines of Perl. If there were a trustworthy auth provider it wouldn't be as bad, but I don't really know of any... maybe something in the Fediverse?

Do you have a link?

I've been looking for some nice Perl solutions, I imagine it's pretty much the optimal language for many of these problems.

Re: Advent of Code 2023 is nigh

#233
post #24

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.

I just created a list of string-value pairs and found first index of and last index of for each of them keeping track of the best first and best last. C# is pretty freaking amazing like that.

I did the same thing, but in Common Lisp.

I'm guessing you're talking about something more C#-specific like LINQ?

Re: Advent of Code 2023 is nigh

#234
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

Re: Advent of Code 2023 is nigh

#235
post #201
post #198

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

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

[deleted]

Re: Advent of Code 2023 is nigh

#236
post #201
post #198

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

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

Yeah, 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 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/3d6f2b87bae4809ef8a062caff7...

C++'s .rbegin() / .rend() reverse iterators made the search fairly trivial.

Re: Advent of Code 2023 is nigh

#237
post #124

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?

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

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

Re: Advent of Code 2023 is nigh

#238
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…)

Re: Advent of Code 2023 is nigh

#239

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.

> As others have said, part 2 of today's was really difficult. I suspect it was purpose-built to foil ChatGPT. I solved it on my own first and then went back and tried to help GPT4 write a solution. Even after carefully walking it through a strategy, discussing edge cases, and having it outline a solution in pseudocode, it still failed completely to translate our conversation into working code. (It didn't even work f…

I got it to work with ChatGPT, took around 5 attempts, but that was mainly me not understanding all the edge cases. Once I came up with a strategy that would work, ChatGPT gave me working code.

My strategy was not efficient, but did work.

I walked the string twice, first LTR and replaced all found strings with numbers, then walked right to left, and replaced all backwards strings to numbers.

Then took the first digit from the left walked string, and the last from the right walked string.

Re: Advent of Code 2023 is nigh

#240

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 chara…

Nice! I also ended up using nom, it was quite fun.

https://github.com/woile/adventofcode/blob/main/2023/day1/sr...

Post reply on HN