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:
If the puzzle is actually another fucking tree I'll jump off a bridge.
Lincoln Lewis
Why the fuck am I always eating when these start? I keep having to rush through my meal. It's not even like it's lunch time of anything, it's fucking midnight.
Benjamin Cox
well you better head out now, you've only got 20 minutes before you need to jump
Kayden Wright
Unlikely, the order of puzzles is partially determined by the results gained from beta testers on each puzzle, so they shouldn't know the final order even if they did leak.
Kayden Watson
Why can't you eat in 20 minutes?
Wyatt Garcia
I set up 10 mins early so I only have about 5, and it's a big meal that's spicy as fuck. I tend to eat slower than average to top it off, too.
Carter Walker
Stress generally makes you hungry.
Carter Perez
Oh, I may have misread that. Whatever. I'm already in the middle of a big meal.
Cameron Cox
>big meal >at midnight y tho
Aaron Robinson
going to sleep hungry is the worst I'd rather eat at night than any other time of day
TRYING NOT TO THINK ABOUT THIS GIGANTIC SHIT I HAVE TO TAKE
Colton Butler
prepping shit
Josiah Reyes
the brainlets were the only thing keeping this fun desu. most of the people left just post their code when they're done and jerk off to how much they can optimize it
Luis Martinez
thinking of going to sleep so I can be well rested at work tomorrow.. do I have the willpower to do it?
David Thomas
>implemented a binary tree real quick just in case the oracle user is right
just reading this made me think "why am i even bothering with this shit"
Henry Jones
I don't understand why is the puzzle input an int rather than a table?
Brayden Rodriguez
for fake points that give a rush of dopamine when you get them
Caleb White
>1 indexed FUCKING WHY
Sebastian Flores
What am I suppose to do with the input number? >t. ultra brainlet
Caleb Smith
i've been filtered, i'm just here to watch /ourguy/.
Jonathan Taylor
he just double starred. post code fren.
Jordan Wright
THE ABSOLUTE STATE OF PETERTSENG
Joshua Davis
>Increase the power level by the value of the grid serial number (your puzzle input).
Brody Edwards
There sure are a lot of these 2d grid questions this year...
Jose Bell
1/8, beat out all 3 of the other contenders today. Also I think petertseng is getting rekt again Wrote part 1 in python but it was too slow for 2 so I rewrote it in C Probably should've just used pypy, I always forget that exists It's actually still pretty slow in C because I used a stupid algorithm, but my target size was only like 14 and it got that far pretty damn quick
class keydefaultdict(defaultdict): def __missing__(self, key): if self.default_factory is None: raise KeyError( key ) else: ret = self[key] = self.default_factory(key) return ret
def calc(data, size=None): try: grid=keydefaultdict(partial(val,data)) mx = 0 retval = 0 for size in ([size] if size is not None else range(1,301)): print(size, retval, mx) for x in range(1,302-size): for y in range(1,302-size): th = sum(grid[(x+i,y+j)] for i in range(size) for j in range(size)) if th > mx: mx = th retval = (x,y,size) except KeyboardInterrupt: pass return retval
if __name__ == '__main__': data = 1723 print(calc(data,3)) print(calc(data))
Almost got on the leaderboard, too.
-------Part 1-------- -------Part 2-------- Day Time Rank Score Time Rank Score 11 00:12:04 379 0 00:17:29 118 0
I actually learned about that keydefaultdict thing today at work when I needed it for something.
-------Part 1-------- -------Part 2-------- Day Time Rank Score Time Rank Score 11 00:11:52 357 0 00:21:52 205 0
I'm #100 now I think it's safe to say it's my last day on the leaderboard
Code btw (still running but I tried the best of size 12 and it worked) arg = 5153 L = [[0 for y in range(300)] for x in range(300)]
for x in range(300): for y in range(300): p = ((((x+10)*y + arg)*(x+10))%1000)//100 - 5 L[x][y] = p
best = -999999999 bestx = 0 besty = 0 bests = 0 s = dict() for x in range(300): for y in range(300): s[(x,y)] = L[x][y] for size in range(1,301): print(size, bestx, besty, bests, best) for x in range(300-size+1): for y in range(300-size+1): p = 0 for xx in range(size-1): s[(x,y)] += L[x+xx][ y + size -1] for yy in range(size-1): s[(x,y)] += L[x+ size - 1][ y + yy] s[(x,y)] += L[x+ size - 1][ y + size -1] p = s[(x,y)] if p > best: best = p bestx =x besty = y bests = size
which indicates that what I'm doing is getting the right answers.
Julian Russell
And for completeness, change that :3d to :03d. Fortunately that didn't bite me in the butt this time.
Brandon Gutierrez
Print the best so far as it finds them. I just tried plain old cpython and it reaches the actual answer in about a minute, long before it would ever finish up to the full size 300
Gavin Young
DON'T WAIT FOR YOUR PART 2 TO ACTUALLY FINISH JUST PRINT YOUR BEST X,Y,SIZE FOR EACH SIZE AND TAKE IT ONCE IT STAGNATES
Christian Carter
You're off by one, my dude
Justin Lewis
I get 285,169,15 for 5093.
Henry Wood
Also make sure to start at 1x1 and not 300x300.
Jonathan Morris
tfw I waited for my part 2 to finish and I got rank 125...
Brody Ward
thx, it stagnated in 1 sec while my previous instance was going already for 5 mins with no answer
Lincoln Morgan
>2nd part taking forever >try the current max value >its right wew.
Adrian Mitchell
Yeah, it's shitty. I swear I saw one of the X,Y examples with a space but it looks like there isn't one. Super shitty to not tell you how to format your input right by the box. They have space for a whole dumb story and no space for a simple input format explanation, since this time it isn't a number.
Jaxson Evans
>waste 5 minutes thinking your algorithm is botched >turns out the array isn't zeroed this is why C shouldn't exist anymore
Jonathan Rivera
>oh wow part 1 was actually really easy, i guess today wont be too ba- >mfw part 2
>spent 35 minutes on part 1 >WHY THE FUCK wont it take 492,455 >I've checked 20 times, it's the right fucking answer >read the question for the 10th time >300x300 grid that's it, I'm done