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:
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
Jonathan Thomas
Who here survived the wall?
Jayden Long
Remember that if you consider this a wall, there's going to be a rude awakening two days from now
Eli Brooks
How does the Jow Forums leaderboards rank people? why are people with 3 stars above people with 4 stars?
Easton Kelly
not considering this wall. What I am considering is not waking up earlier to attempt and solve these issues before going to work.
Isaiah Scott
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.
Lucas Butler
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
Aaron Fisher
>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
Jaxson Edwards
Wait until the multi threaded knot hashing emulator reverse engineering a bridge to the finale shows up