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:
Still stuck at part 2. I check whether the current pattern matches the last pattern to detect when the sliding starts I take the sum of the last pattern before sliding Then I take the count of pots in the first sliding pattern I multiply the amount of pots with (50000000000 minus startnumber of sliding pattern) and add the result on top of the sum What am I doing wrong?
What you wrote is all right. Probably implementation mistake, check for off by ones.
Robert Bennett
Can you give your input & your solutions so I can check?
William Jenkins
I'm not sure it I should be pleased or disgusted with my solution for part 2. start = 50000000000 print(sum(range(start-92+5, start-92+5+186, 1)))
I got fucking lucky with my input, it' converges on a solid line 186 long moving right, starting on gen 92. I just dumped 100+ generations to a text file and looked at the row/column it got stuck. Pen and paper without the pen and paper.
Does anyone have an input, along with its solution, where the repeating pattern shifts by some amount *other than* by one to the right? Want to verify my implementation.
ok this is the first input since last and this thread where my part one is incorrect, so I would guess somethings still off
Lucas Perez
Shit, sorry, part 1 is 2911. I played around with Part 1 when I aimed for Part 2.
Brandon Green
Ok then my part 1 is working. I'm getting 2499999999397 for part 2, which is -1298 below your result. Which of my vars is most likely off by a few?
Nolan Cooper
>Pen and paper without the pen and paper Are you fucking shitting me with that line?
Mason Green
by the way, this is my output. offset is the offset from the initial 0 point pastebin.com/raw/nL6N7Ybx
Christian Perry
Looks allright, what is the semantic meaning of "offset"? Mine also starts repeating at gen 91.
Robert Cook
if this is the initial state ##.#...#.#.#....###.#.#....##.#...##.##.###..#.##.###..####.#..##..#.##..#.......####.#.#..#....##.# I check 4 - indexOf('#'), so in initial state index of the first # is 0 -> I add 4 dots to the front and increase the offset If there are 5 dots infront this will be -1, so I remove 1 dot from the front and decrease the offset
Carter Watson
Everytime there's a calendar brainlet. The calendar updates on FRIDAY of the WEEK!
Elijah Morgan
Offsets also seem allright. You just fuck up the final calculation somehow.
Hudson Williams
solved it. checked the wrong generation state at one point during calculation. thanks for helping and comparing user
what kind of concepts do you think might pop up further along the way?
Jordan Watson
Does anyone know of a Life program that can handle these rules? I want to see if they can handle true bigboy rules. Hashlife and everything else in golly don't seem to support range 2 neighborhoods.
Levi Wilson
checked
Noah Morgan
I toyed with the idea to use golly. You can rewrite range 2 neighborhood rules to range 1 multi state rules.
big_boy rules produce linearly growing "plant range". At the 50000000000th round one would need ~12GiB of ram to store only the plant's positions. An inplace updating mechanism is warranted (as opposed to the naive double buffering). Not to mention that by the end you have to read that 12GiB every single round.
Robert Hernandez
have you guys heard of L-systems? the task comes down to derivation of context L-systems, or (2, 2)-systems to be precise, because of the lengths of left and right context you can draw all kinds of shit with them & turtle graphics, including the subject of my diploma thesis, procedurally generated plants
Fucking saved. You just store an offset. The nth element of the array refers to the (n + offset)th pot. offset can be negative.
Hudson Roberts
Now I feel stupid.
For the non-chaotic growth rules, a good simulator like hashlife can compress the data trmendously. But I guess for rule 30 and friends I'll only crash my computer halfway through.
Grows both ways by 2 in every turn. I don't see any compressible pattern, it would need ~24GiB of memory to store the state at the 50000000000th round.
There wasn't really anything that screamed tree about yesterday, if that's what you're going for. Pyfags getting fucked is definitely a good highlight, but the visualizations are the best part of the day desu. If I knew where to take it I would probably give it a go, but I unfortunately don't really.
Blake Barnes
>but the visualizations are the best part of the day true, also I'm surprised that there were no "power level" jokes.
Lucas Diaz
I did the second part by hand. First I got the part 1 answer then I just changed 20 by 50 billion and as it was taking too long I killed the program and then tried 1000 and got 61491. Then I tried 10000 and got 619491. so: 1000 -> 61491 10000 -> 619491
wtf is this live power being put through a big ass pole?
Brody Green
looks like a shabby connection to a ground rod
Isaac Young
Me and another user who posted use pygame, I posted a script last thread here that can do one for the day. Pygame is pretty old and somewhat outdated, but it's great at this kind of 2D stuff (I especially use image.frombuffer() in these). I have my own basic 5 KB framework for it, but it really doesn't really need much boilerplate to get working (as seen in my post). I've used it for many visualizations, tools, demos, etc. It is technically intended for games, but it's rarely used for anything notable for performance reasons, other than the ren'py visual novel engine (Katawa Shoujo, Doki Doki Literature Club, etc.).
Webm related is one I made for last year. Pygame has no 3D functionality by default, I wrote my own crappy 3D code for this. It is however made to work with PyOpenGL for 3D things. If you have questions, feel free to ask.
>Pygame has no 3D functionality by default, I wrote my own crappy 3D code for this. whoa, cool stuff
Jayden King
I use imsave from scipy.misc feed in a numpy array get a png, simple as that.
Kayden Turner
What the fuck is day 6 part 1 and how the fuck do I do it? This is as far as I got in python.
with open('day6/aoc.txt', 'r') as f: coordinates = f.readlines()
grid = [['.'] * 500 for i in range(500)]
for iter, cords in enumerate(coordinates): x = int(cords.split(',')[0]) y = int(cords.split(',')[1][1]) grid[y][x] = iter
I found that I can use scipy for this, but that is only to calculate distance, I would rather solve this on my own. Also even if I am able to calculate the distance between two points, how do I get the area? Do I just divide the distance by half between all points that it borders and calculate from there?
Nathan Nguyen
It's shite, but it works. No texture mapping in my code though, I'll post a screenshot of how that went in a moment.
the easiest option is just computing the nearest point for every point in the grid
Isaiah Wilson
Here you have it, texture mapping on the CPU with python. Not even numpy or cython. The reason the framerate is even that high is that that's the lowest the counter I made goes.
I think it would probably be better with the posts up in just the black area only
Noah Jackson
Today wasn't brainlet filter since I made it.
Luis Evans
manhattan distance is sort of a simplified heuristic of euclidean distance - you just calculate the absolute value of the difference between x and y coordinates of two points and sum them up, no square root bullshit; that is abs(x1-x2)+abs(y1-y2) then you have to deal with the infinite areas. But you can easily find which of them are infinite by noticing that any area laying on an edge of a boundary box enclosing the points is infinite (a box such that every point is within it) do the calculations for every point within the box, discard infinite areas and viola
Camden Collins
>texture mapping on the CPU with python madman
Jason Stewart
>But you can easily find which of them are infinite by noticing that any area laying on an edge of a boundary box enclosing the points is infinite
Yo I love the 3D stuff you managed, but since it's just acting as a wrapper for SDL, why do you write this in pygame?
Austin Kelly
it can be infinite even if it's not on the edge it just needs to be closer to that edge than any other point
Julian Jackson
>But you can easily find which of them are infinite by noticing that any area laying on an edge of a boundary box enclosing the points is infinite >any area
>it can be infinite even if it's not on the edge that's not what I meant; I didn't mean the pivot point if the "c" area is infinite, it has to cross the boundary box somewhere; this is the same for every infinite area so to find infinite areas you just have to follow the edge and put them into a set otoh the finite areas will make up a convex shape, which means no finite area will cross the box
Isaac Jackson
Got filtered hard on this one boys, had to dissect another user's code just to wrap my head around what was going on. Thought I had a working idea but apparently I just wasn't getting it. Feels real fuckin' bad man. Hopefully tonight's works out better :(
Why do they troll us? Why? I rewrite my OCaml code to an efficient C code, but it was still too slow, so I look. Fuck off, I solve it, but it was stupid.
Julian Ortiz
create two distance fields, one at some large value bounds, and one slightly larger
the infinite areas are which ever areas are different between the two
Sebastian Hernandez
how are you gonna contain an infinite area in a finite bounding box?
Cooper Rogers
how is it false? how can an infinite area be enclosed within a finite rectangle box? it has to cross the box somewhere
Isaac Wright
I find it really strange that this one was hard for so many people I thought it was the easiest one in a long time it's just like a dozen lines in C++ compared to all my other solutions which are literally 2-3x longer all I did was map the inputs to the outputs and do a couple loops and that's it
Parker Sullivan
it can be finite and "close up" farther down outside the bounding box
Landon Smith
Difficulty peaked around day 7-8. Are we in for another brainlet filter soon?
Jackson Adams
Not with manhattan distance.
Joshua Smith
Why? #define F(i) (-(i) - 1)
typedef long int pos_t;
static unsigned int *left; static unsigned int *right; pos_t mini = 0; pos_t maxi = 0; static int rules[32] = {0};
static int get (pos_t i) { unsigned int *ptr; pos_t q; pos_t r; if (i < 0) { i = F (i); ptr = left; } else { ptr = right; } q = i / 32; r = i % 32; return (ptr[q] & (1 > r; }
static void set (pos_t i, int x) { unsigned int *ptr; size_t q; size_t r; if (i < mini && x) { mini = i; } if (i > maxi && x) { maxi = i; } if (i < 0) { i = F (i); ptr = left; } else { ptr = right; } q = i / 32; r = i % 32; if (x) { ptr[q] |= (1
Isaac Watson
The only language I am any good at is python, having only done a little C++ for an arduino and basic lua before. As far as pygame over other libraries, it's just the one I'm most familiar with. The 3D stuff was always just an experiment of mine, starting with crude 3D effects in lua with absolutely no graphical interface - Writing to a buffer of text and printing it out all at once at ~20 FPS. The flickering in the webm isn't a conversion artifact, it's because the framerate doesn't line up with the printing and I'm not aware of a way to directly edit the text on the command line, despite searching and asking in the /sqt/.
with the rules we were given, at some point the pattern stops changing and just shifts to the side. at that point you can calculate the point increase from one iteration to the next and use it to calculate the value at any number of iterations after that