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
It's fine, you might even be able to compete on today's problem if it doesn't build upon a previous problem
Shit's underdocumented as fuck, just do "pip install z3-core"
Caleb Perry
There's no time limit, although the threads this year will stop after the 25th/26th if people are catching up. Feel free to join, although last year's puzzles were better than this year's.
Asher Murphy
>z3-core z3-solver My bad
Evan Roberts
What is this shit, what's "Z3" and why do you need some Microsoft product to solve last day's problem?
Jace Russell
thanks user, i'll be doing it in c++, i hope that's not too retarded as these seem to be meant for scripting languages ?
Wyatt Allen
Although, I just remembered that the 200+ euro raffle ends on the 7th. 36 stars for 1 ticket and all 50 for 2.
Owen Peterson
I implemented my solution and so far it seems to do great. (even though it is quite slow) it solved my own input and correctly. Can you guys give me some more test inputs?
Wyatt Nelson
It's generally faster to write programs and thus make the leaderboard with scripting languages, but if you're not trying for the leaderboard c++ is fine. It's not made for any language in particular.
Christian Ward
That's exactly what led to said install error. It sounded extremely slow, I've been trying to avoid that because I sometimes have hundreds of tied solutions on a step, each of which will have even more tied solutions on the next iteration. How is yours running fast enough?
Charles Nguyen
>That's exactly what led to said install error. Then I guess you need the sudo apt-get install z3
Nathaniel Watson
I caved in and copied a Z3 solution this morning just to pass, but gonna try again to solve this with LP, assuming I can remember shit
Nolan Powell
They don't want you to use GNU tools on windows. MINGW build fails with the error you mentioned. MSYS build succeeds but it looks for the lib with extension .so. After patching it to use the extension .dll, the build succeeds but segfaults. I just ended up using a Z3Py binary release for win64 with mingw64-python. The release version segfaults as well, but the nightly build didn't.
Aaron Scott
pastebin.com/p8hbRzRU 297/126233088 My solution was complete bullshit, so I'm not going to bother checking it with anything else
Nathaniel Morris
Meant to be a reply to and
Joseph Gray
I sort by intersection count first and then by manhattan distance as second criterion to break ties. then I work from the best candidates downwards. The solution converges quite quickly to the correct result (which I knew before ), but then I also get issues with tied results, since I cannot actually exclude them to be certain my solution is actually 100% correct. I cannot prune them, because I do not know exactly where they will end up when scaling them. :/
Ayden Gray
>So is the solution for part 2 really to learn how to use z3? This is bullshit. No, you can do recursive subdivision instead Z3 might be easier though, I don't know what those solutions look like
They threw an NP-hard problem at us with a respectably sized data set and unless someone comes up with some way to exploit some quirk of the way the inputs were generated (or prove that P = NP lol), the best way any of us have come up with to solve this problem are with generally unreliable approximation algorithms (most of the last thread), or to bring out the heavy artillery by reducing the problem to a version of the maximum satisfiability problem, then feed that into a generic solver (Z3).
Some of us got inputs that shitty approximation algorithms work on and got their answer pretty quickly, but others (like me) got unlucky and had to take the latter approach. It's pretty bullshit desu
x, y, z = Int("x"), Int("y"), Int("z") tuplized = [((tuple(b[0:-1]), b[3])) for b in parsed]
orig = (x, y, z) cost_expr = x * 0 for pos, range in tuplized: cost_expr += If(z3_dist(orig, pos)
Josiah Rodriguez
>P2: (45591145, 26525958, 51239070) len 123356173 Fuck, my program fails on that one :(
Liam Rodriguez
This shit was fun last year and the threads were way more active.. I'm pretty salty about today
Ian Davis
Is that X,Y,Z ? If I check 45591145, 26525958, 51239070 specifically, my program says there are only 190 bots in range. Doesn't seem right, but I don't think I fucked up checking a solution either.
Nicholas Hall
>pastebin.com/p8hbRzRU yup, can reproduce (about 3 minutes till it converges, remaining elements to check (to be 100% certain) probably some hours, lul but this can be optimized. but for now I am happy with the algorithm. Much better than the guess and guess again method I had before. (-943, 88346877) (23175670, 25455557, 39715650)
is what my program is stuck on right now, I will let it run, in theory it should at some (reasonable) point in time reach the solution.
Zachary Gomez
Good question, it's just what the program I posted along with it spit out. You might have to try different permutations to figure out if the order got mangled somehow. I don't understand this z3 shit, it filtered me pretty fucking good.
Jacob Cruz
My program instantly says the answer is Distance = 88894457, Coords = [23449460, 25729347, 39715650], Bot Count = 977
No idea if it's right though.
Jose Edwards
>P2: (45591145, 26525958, 51239070) len 123356173 Is this an answer to a different input or something? Because this point only has 190 bots in range on the input in that pastebin, while point (23449460, 25729347, 39715650) has 977
Tyler Morris
Fuck, yes, it is. P2: (23449460, 25729347, 39715650) len 88894457 I accidentally copy/pasted the output from a different input and never double checked. Sorry, I'm retarded.
Caleb Williams
>but others (like me) got unlucky and had to take the latter approach. It's pretty bullshit desu You should demand a refund.
Joshua Hall
> NP-hard Nothing about this problem is NP-Hard, as far as I can tell. Brute force should be polynomial; it's just polynomial with a huge n.
Jacob Powell
it is polynomial in the size of the coordinates. but this means it is exponential in the size of the input. (which is log(n)) so it only pseudo-polynomial. Someone earlier mentioned some reduction, so it might as well be NP-hard.
Isaac Watson
The input size (as in the literal byte size of the input file), depends on the size of the coordinates. It's obvious that you can reduce this to MAX-SAT. It's not obvious to me that you can reduce MAX-SAT to this problem.
Aaron Perry
Day 23 is fucked up or it's me?
It took this for valid: 10615635,41145430,30249331 = 82010396 (981 bots)
It's really common on this problem to get entirely incorrect coordinates and still get the right answer, probably something to do with the input generation algorithm or some shit.
Oliver Lewis
The one with Z ending 331 actually has 983 bots (not 981) The one ending 333 only has 973 (not 983)
Lincoln Sanchez
This succeeded where my fucking around with divided radii in hopes of grabbing the right hitcounts while excluding false positives failed. I still don't really get how z3 works with somehow recursively running through references but it's cool.
Grayson Brooks
wew, thought my approximiation algorithm finally failed on one
Dylan Davis
I refined the idea of solving the problem iteratively at different scales and using this heuristic to converge quickly. I now rescale by a factor of 2. and so far it works pretty quickly (
Luis Watson
>Someone earlier mentioned some reduction, so it might as well be NP-hard. I would like to see a reduction from MAX-Sat to 23 part 2, but if one exists it certainly isn't obvious. We may as well consider 2-MAX-SAT which is also NP-Hard. Thus we want to take a formula that is a conjunction where every conjunct is a disjunct of two variables, and map it to a list of nanobots. If the formula has n variables, then there are 2^n possible assignments. How on earth would you map these 2^n possible assignments into the 3d space of the problem, and map each disjunction of the form (p OR q) to a nanobot whose range contains every point corresponding to an assignments with p true or q true? It sounds utterly impossible to me. That's not to say there isn't some reduction, but if there is, it's not as simple as people are assuming.
Cameron Walker
>How on earth would you map these using perl or sed ;^)
Angel Gray
there's binaries, use the nightly one because the legacy and "release" ones are super outdated github.com/Z3Prover/bin
Parker Rodriguez
It's just super lame when you're trying to do a skill-based programming challenge and many people including most who got on the top 100 leaderboard got to use much less skill
Probably not going to bother with AOC next year, this one has been a real drag. I'm gonna finish it though because I can't let Eric Wastl get the better of me.
Jackson Adams
The "lucky"/rigged inputs are okay when they're obvious, like when you can just glance at the input or write 1-2 lines of code and see that it has some useful property you can exploit. But here, checking the property is at least as hard as solving the actual problem, so basically the only way to take advantage is to guess and commit to a possibly-wrong solution up front.
Dominic Reyes
It's still lame when one portion of people get an easier problem to solve than the rest
Jayden Myers
All the inputs are at least rigged to have a unique point with max bots, as far as I can tell Also, there aren't a lot of near-miss overlaps, which is the reason the resolution scaling solution (mostly) works I'm not sure any input is actually strictly easier. I think resolution scaling should work on every input, but not necessarily with the exact same parameters.
Landon Sanchez
I don't think the inputs were of different difficulty. it was just that for each input only some of the heuristics worked. So it was much more of a gamble. (maybe apart from the SAT-solver problem killer, but it doesn't feel like this was the intended way to do it)
Wyatt Stewart
My first attempt at an algorithm would've gotten me rank 50 or so on the part 2 leaderboard if I had gotten an easy input, which I only found out later after going back and running it on some other anons' inputs after giving up and doing z3 shit this afternoon. I really wouldn't have deserved it though, my best rank for the entire year is 500ish on today's part 1, though I guess that's partly because that was only the third or fourth time I looked at the puzzle when it released, but mostly because I'm a slow, mediocre programmer.
John Scott
>maybe apart from the SAT-solver problem killer Recursive subdivision works too if you compute the upper bound precisely. ("Upper bound" for a region R being a number N such that num_bots_in_range(P)
Henry Walker
>I really wouldn't have deserved it though You would've deserved it as much as any of the people who got lucky
Sebastian Nguyen
lol i usually spend an hour deciding if i should parse the input with streams or scanf, then another hour debugging the parsing
Owen Robinson
>slow, mediocre programmer Doesn't matter so much on problems like 23b that rely much more heavily on coming up with a good algorithm than on the actual programming
Brandon Flores
>Tfw forgot how to do abs formulas in LP Fug
Jaxon Garcia
i can come up with a million good algorithms in my head, but it somehow has to become machine readable
Andrew Lee
That's just silly There's no reason you couldn't have written a bunch of text parsing helper functions by now Since almost every question starts with parsing the input text
Joseph Hughes
I just realized that scaling () is exactly the same idea as subdivision (here into sets of size of powers of 2) and your "upper bound" is the heuristic of adding a small bit to the radius. I missed that completly up till now.
Isaiah Perez
>t. hasn't used scanf and it's gorillion flags or std::cin's quirks
Brayden Clark
>not using a good language
Cameron Scott
I absolutely have to leave at 7AM if I want to see my family for christmas so I hope today's problem won't be too long
>Solve this modified grid recursive halting problem written in elfcode that is somehow SAT solvable
Luke Stewart
>I'm still back on day 20 Damn. I also insist on doing them in order, too.
Kayden Rodriguez
>your "upper bound" is the heuristic of adding a small bit to the radius Not sure what your heuristic is but that doesn't sound right to me. Upper bound in my approach is literally the exact number of bots whose octahedron overlaps the region R in at least one point. Being able to compute this exactly means you can stop the search as soon as you've found a point and all remaining regions have smaller upper bounds (for me this is usually within 5-10s).
Jonathan Smith
Today had better not be more asm reverse engineering bullshit
Nathan Ramirez
but it's the only thing I'm good for
Gabriel Robinson
Do you think Eric will have mercy on us? It's almost Christmas...
ok, the heuristics are not the 100% the same. but if I scale down the problem by 2**n and increase all radii a bit this has almost the same effect as considering boxes of side length 2**n and looking for intersections with these boxes. since "scaling down" the coordinates effectively "scales up" the "unit boxes"
Chase Howard
Never, I'm going to post it every day next year too
Dominic Green
TWO MINUTES
Leo Cox
time for NP-hard 4d elf assembly problems!
Jordan Taylor
Oh shit, I just realized I've been up for 24+ hours I'm the user who missed the last puzzle because I was playing sudoku on the shitter and lost track of time
Isaiah Reyes
OH SHIT I GOTTA FUCK
Andrew Ross
FUCK
Eli Kelly
FUCK! second to last chance to redeem myself!!
Ryder Powell
FUCK
Adam Turner
WALL OF FUCKING TEST I'M OUT
David Kelly
ugh fuck this
Sebastian Watson
IT'S JUST BUILD A FUCKING ROGUELIKE COMPLETE WITH MAGIC SYSTEM
WTF IS THIS SHOT LMAO Immune System: 2991 units each with 8084 hit points (weak to fire) with an attack that does 19 radiation damage at initiative 11 4513 units each with 3901 hit points (weak to slashing; immune to bludgeoning, radiation) with an attack that does 7 bludgeoning damage at initiative 12 5007 units each with 9502 hit points (immune to bludgeoning; weak to fire) with an attack that does 16 fire damage at initiative 2 2007 units each with 5188 hit points (weak to radiation) with an attack that does 23 cold damage at initiative 9 1680 units each with 1873 hit points (immune to bludgeoning; weak to radiation) with an attack that does 10 bludgeoning damage at initiative 10 1344 units each with 9093 hit points (immune to bludgeoning, cold; weak to radiation) with an attack that does 63 cold damage at initiative 16 498 units each with 2425 hit points (immune to fire, bludgeoning, cold) with an attack that does 44 slashing damage at initiative 3 1166 units each with 7295 hit points with an attack that does 56 bludgeoning damage at initiative 8 613 units each with 13254 hit points (immune to radiation, cold, fire) with an attack that does 162 radiation damage at initiative 15 1431 units each with 2848 hit points (weak to radiation) with an attack that does 19 cold damage at initiative 1
Infection: 700 units each with 47055 hit points (weak to fire; immune to slashing) with an attack that does 116 fire damage at initiative 14 2654 units each with 13093 hit points (weak to radiation) with an attack that does 8 radiation damage at initiative 19 5513 units each with 18026 hit points (immune to radiation; weak to slashing) with an attack that does 6 slashing damage at initiative 20 89 units each with 48412 hit points (weak to cold) with an attack that does 815 radiation damage at initiative 17 2995 units each with 51205 hit points (weak to cold) with an attack that does 28 slashing damage at initiative 7
Nicholas Perez
Also, merry christmas fuckers
Ayden Peterson
Jesus christ is this happening again? The last time I did AoC prior to this year was in 2016 when I took one look at day 11 and couldn't be bothered to untangle that shit, this looks even worse.
Levi Reed
gonna hand-convert this input to my code because fuck parsing this
Austin Gutierrez
someone doesn't seem to like a peaceful christmas.