/aocg/ - Advent of Code 2018 General #14

Fine I'll Make The New Thread Edition

Previous thread: adventofcode.com/
>Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.
You need to register with an account but you can appear as anonymous.

Private leaderboard join code:

368748-e33dcae3

People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.

Alternative leaderboard for those waiting for inactives to be kicked from the first:

208834-4a1a9383

Attached: 1530801101048.png (1000x1000, 712K)

Other urls found in this thread:

pastebin.com/qwSjEqBb
pastebin.com/MZyeeAnD
pastebin.com/3fW3sf3a
pastebin.com/MqB5dksa
mega.nz/#!Ro1BkKyS!asDqLa5PRI-JTJJnv6k9Ujt3fjxJ1gTG55vg9E2yHxg
pastebin.com/x5UcedBR
pastebin.com/3gCxhyQ5
twitter.com/NSFWRedditGif

Will post question here again.
def part1(logs):
guards = defaultdict(list)
currentGuardID = None
minuteFallenAsleep = None
for log in logs:
currentMinute = int(log.split(" ")[1][3:5])
if "Guard" in log:
currentGuardID = int(log.split(" ")[3][1:])
minuteFallenAsleep = None
elif "falls asleep" in log:
minuteFallenAsleep = currentMinute
elif "wakes up" in log:
guards[currentGuardID] = guards[currentGuardID] + \
list(range(minuteFallenAsleep, currentMinute))

sleepyGuard = None
currentMax = 0
for k, v in guards.items():
if len(v) > currentMax:
currentMax = len(v)
sleepyGuard = k
return sleepyGuard * Counter(guards[sleepyGuard]).most_common(1)[0][0]

Anyone have any clue why I'm not getting mine to work? I'm adding every guard and a list of all the minutes the dude is sleeping, then I'm checking which guard has the most minutes slept and returning his ID * the minute he slept the most. The logs are sorted

Who here survived the wall?

Remember that if you consider this a wall, there's going to be a rude awakening two days from now

How does the Jow Forums leaderboards rank people? why are people with 3 stars above people with 4 stars?

not considering this wall.
What I am considering is not waking up earlier to attempt and solve these issues before going to work.

Repostan for ideas what happened:

Welp, that was tougher than I thought it would be. I got the math right but the dates got fucked during sorting.
Background: I had to add +1 to the month because it was 0-11. After sorting, the values were back to -1. Tried with std::sort and my own implementation of merge sort but same happened with both.

I had a std::vector where entry had a timestamp field with a std::tm struct where I changed the month with timestamp.tm_mon = 1 + timestamp.tm_mon.

Looks reasonable, does it work on the test input? Try printing a slice of data at a few points to see where it's going wrong

>tfw there's probably a way to abstract all the various queries I'm doing to one higher order function
>tfw don't know what it is

Wait until the multi threaded knot hashing emulator reverse engineering a bridge to the finale shows up