r/adventofcode • • Dec 04 '18

SOLUTION MEGATHREAD -πŸŽ„- 2018 Day 4 Solutions -πŸŽ„-

--- Day 4: Repose Record ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 4

Transcript:

Today’s puzzle would have been a lot easier if my language supported ___.


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

38 Upvotes

340 comments sorted by

View all comments

Show parent comment

2

u/sebranly Dec 04 '18

You're right, it looks like I was completely wrong. I just spent some time cleaning my disgusting code before pushing it (it's still ugly), and I noticed that for some reason I don't have the unexpected behavior anymore. The code in which I had the unexpected behavior is the following: https://pastebin.com/Yb0zdgj2 (L105). Note: create2DArray simply creates a 2D array of width x height elements.

Disclaimer: it's really really ugly.

0

u/sebranly Dec 04 '18 edited Dec 04 '18

Ok I got it, silly mistake from my side, partially due to my data being wrong:

...
Guard 727 set a new record of 13 thanks to minute 37
Guard 971 set a new record of 13 thanks to minute 30
Guard 971 set a new record of 13 thanks to minute 31
Guard 971 set a new record of 13 thanks to minute 32
Guard 971 set a new record of 13 thanks to minute 33
Guard 971 set a new record of 13 thanks to minute 35
Guard 971 set a new record of 14 thanks to minute 36
Guard 971 set a new record of 14 thanks to minute 37
Guard 971 set a new record of 15 thanks to minute 38
Guard 1877 set a new record of 15 thanks to minute 43

whereas with `>` (incorrect), I'd get:

...
Guard 727 set a new record of 13 thanks to minute 37
Guard 971 set a new record of 14 thanks to minute 36
Guard 971 set a new record of 15 thanks to minute 38

3

u/SilverSlothmaster Dec 04 '18

Guard 971 set a new record of 15 thanks to minute 38

Yeah, not sure why you're setting a new record of 15 for 971, he never sleeps 15 times for the same minute. I assume you had some error in your code before getting there.