Live data from Hacker News

Advent of Code 2023 is nigh

adventofcode.com

221–230 of 319 posts

Re: Advent of Code 2023 is nigh

#221

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

> secondarily about submitting a solution as quickly as possible if you want to be on the leaderboard. Is that right?

That's probably closer to #10, as it requires being available right as the problem drops (midnight EST and 6AM in europe, IIRC), and generally mid-cycle puzzles require being very good at solving these kinds of puzzles.

Last year, betaveros topped the leaderboards with a bespoke language they designed for the task (https://github.com/betaveros/noulith).

Re: Advent of Code 2023 is nigh

#222
post #187
post #8

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

The quickest time of the first star is suspicious...

Can you elaborate? I think I recognise your username :-)

Re: Advent of Code 2023 is nigh

#223
post #27

Earlier quoted context omitted.

Generally, such edge-cases usually make the solution ugly and the process unpleasant. The aim of such puzzles should be a pleasant process culminating with a beautiful solution.

The potential for overlapping numbers was the thing that tripped up many developers. But a simple “find the first number searching from each end, just like the puzzle instructions asked” implementation just worked. The lesson is to read the puzzle instructions carefully and avoid solving more general problems.

Same here, I also didn't use the replace-strategy nor regexes.

Re: Advent of Code 2023 is nigh

#224

Earlier quoted context omitted.

So are you saying that overlapped characters can be used for both numbers? Meaning: - eightwothree -> 823 (answer 83) - 4nineeightseven2 -> 49872 (answer 42) - zoneight234 -> z18234 (answer 14) I interpreted the instructions as saying to take the first match from the left and not count the overlaps. Unfortunately this gives the same answer as the overlap interpretation on the examples given in the problem statement:…

It could have been more clear. The wording from the problem is "the last digit on each line". To me, that pretty clearly implies "the rightmost substring containing a digit", but I guess I can see how someone could question that interpretation.

Right, but we read the word "eight" from left to right -- to me it is non-obvious that "eightwo" should be counted as two digits when (a) there aren't enough characters to actually make both digits and (b) there wasn't a single example showing this overlap expanded

But I suppose can see the other side as well: the wording makes it sound like any spellings of those digits _counts_ as a digit rather than should be _replaced_ by a digit.

However I think the ambiguity here made the puzzle more difficult in a non-fun way.

Re: Advent of Code 2023 is nigh

#225

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.

Another option when using regex would be to use the lookahead[0] operator (as long as supported, which is the case for the python re module) (?=(one|two|three|[...])) would return `["two", "one"]` for the input string `twone` since the lookahead operator doesn't consume the next character. [0] https://www.regular-expressions.info/lookaround.html

Another trick is you can put some regex engines in right-to-left mode, so my lazy (and admittedly relatively expensive cpu-wise) solution was to match ltr for first and rtl for last.

Re: Advent of Code 2023 is nigh

#226

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

I like powerful languages without a too many built in convenience features.

That way I get to enjoy solving the problems myself without too much effort.

Re: Advent of Code 2023 is nigh

#227
post #183

Earlier quoted context omitted.

I heard the question was difficult before solving it, and then I was surprised when I didn't hit any speed bumps. The overlapping case didn't even occur to me. It turns out I stumbled upon a simple solution: use two regexes. One to match the first digit, and one to match the last. Then the overlapping is a total non-issue.

If the whole numeric part of the string was something like "eightwo", I think that solution would fail.

As a matter of fact, it does not.

https://mutraction.dev/link/c3

Re: Advent of Code 2023 is nigh

#228
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/...

Ahh, people are trying to do a replacement before finding tokens. I wondered why so many people were saying this was difficult. My head went straight to token parsing, which given the limited set of tokens made it trivial. Thought I was missing something

Re: Advent of Code 2023 is nigh

#229

Earlier quoted context omitted.

I also started to write a finite state machine for part 2 but found it too tedious to craft by hand. How did you do it?

Not OP, but I too first thought of a state machine. As soon as I started to write it I realized I was over-solving a day-1 problem. So I switched to brute force https://pastebin.com/r1jNCSdm Once I get a line back from that, it's the same problem as part A.

I made use of the fact that "egrep -o [some regex]" will print the first (going left-to-right) match for the regex. So I ran egrep -o, and several other programs, once per line of input. (And to go from right to left, I used "rev" and an egrep on the reversed string.) My computer wept, but it worked.

  pbpaste | bash -c '
    tt=0
    while read x; do
      y=$(( 10 *
            $(echo $x |
              egrep -o "[0-9]|one|two|three|four|five|six|seven|eight|nine" |
              head -1 |
              sed -E "s/one/1/; s/two/2/; s/three/3/; s/four/4/; s/five/5/; s/six/6/; s/seven/7/; s/eight/8/; s/nine/9/")
          + $(echo $x |
              rev |
              egrep -o "[0-9]|eno|owt|eerht|ruof|evif|xis|neves|thgie|enin" |
              head -1 |
              rev |
              sed -E "s/one/1/; s/two/2/; s/three/3/; s/four/4/; s/five/5/; s/six/6/; s/seven/7/; s/eight/8/; s/nine/9/")))
      tt=$((tt+y))
    done
    echo $tt'

Re: Advent of Code 2023 is nigh

#230
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…

Some people care about the leaderboard, but that's not mandatory. I don't see how the fact of its existence diminishes the experience of someone who never looks at it.
Post reply on HN