[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: noormandy.jpg (213 KB, 1200x966)
213 KB
213 KB JPG
One day to D-day edition

>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
https://adventofcode.com/

/g/ leaderboard join code:
224303-2c132471
anonymous-only leaderboard:
383378-dd1e2041

Previous thread: >>107498650
>>
File: solve_python.png (1.28 MB, 5654x7092)
1.28 MB
1.28 MB PNG
idiomatic Rust/python solution
>>
>>107503926
how tf do you post instantly on new threads lol
>>
>>107503933
He eagerly awaits them
>>
>>107503933
I have my own 4chan archiver running that also alerts me when certain threads get created.
>>
>>107503926
It's called pyrustihonic
>>
>>107503968
pythiomatic rust
>>
C code with heuristic to limit post gauss elim search space: https://pastebin.com/H0qajEyC

>"day10": {"part1": "218.30 µs", "part2": "75.16 ms"}

for that one anon from last thread who asked for it
>>
>>107503982
apologize for what? anon, making hard puzzles is not hard. just pick one of the hard problems and wrap it up in text. what's hard is making fun and solvable puzzles. puzzles that can have various different solutions. puzzles that have easter eggs hidden. anons can solve it after struggling and still find different and interesting solutions of other anons.

wtf did he even intend with p10? to challenge the 10 second rule? I have seen z3 solutions taking 8s.

>>107504045
that was me. thank you <3
>>
is there actually some way to do this without equation solver?
im trying some approach of checking GCD of remainder jolts and then seeing if we can do something like steps to get to (jolts / gcd) * factor
doesnt seem to be working though, im guessing this is not getting the shortest path as there could be some more optimized path that doesnt shortcuit based on this
>>
>>107504087
yep, no greedy way as this is a NP hard problem I heard
you can phrase the problem as solving a system of linear equations with non-negative integer solutions. see this anon's brief idea >>107501142
>>
>>107504087
>is there actually some way to do this without equation solver?
write the equation solver.
>>
File: retepymra.jpg (38 KB, 686x386)
38 KB
38 KB JPG
>only 12 hours to go

DO NOT get up to poop, hold the line
>>
File: carbon.png (718 KB, 1400x5858)
718 KB
718 KB PNG
>>107504045
nice one, anon.
I tried the same, but using "import solution".
taskes about 2s and is much slower than just solving the MILP directly...
>>
Im trying to figure out if this will work but I have no idea on how to prove it
>Start from the highest joltage.
>Find the most direct way to reach it (so if you have a button that increases just it, press only it)
>Then for the next highest joltage, find the least amount of presses you have to add to reach it (so if a button includes it and the highest joltage, replace n presses of the previous button with presses of this button).
>Similar for the next joltages, skew the current minimum by as little as possible
>>
File: out.png (933 KB, 5736x4511)
933 KB
933 KB PNG
import solution
>>
>>107503959
How do you deliver your alerts? Desktop notifications or what?
>>
fuck it im wasting my time on this retarded puzzle
>>
>>107504415
this'd only work if each button affects one counter, because otherwise you might overshoot a counter that you currently aren't focusing on, i think
>>
>>107504427
how'd you get the image. silicon?
>>
>>107504415
yeah, you can do a lot of pruning, I tried something like this but the resulting solution space is till too big to be feasible. I also attempted dynamic programming, because it smells of it, but then the memory is not feasible, because it's an equal trade for computation. Most pruning you can do is by Gauss on the system of linear equations. Or just import solution for MILP.
>>
>>107504455
The idea is that when you find a joltage for which you overshot, you reduce the button presses that caused it to overshoot and you try to find the rest by readjusting the other button presses. Not sure if this ends up being bruteforce with extra steps. My intuition says that there is an efficient way to retune them, by redoing the above for a smaller set if joltages perhaps.
>>
>>107504467
No, I extract my code to html with the TOhtml command in vim and then give the html files to a little python script that uses html2image and pillow to construct the image.
>>
>>107504415
>>107504515
i was thinking of something similar except i'd do it ordered by length of the wires list e.g. the optimal solution should make use of the buttons that increase the most things at once as much as they can
but got bored after trying various other things and seeing they dont work so cant be bothered anymore
>>
>>107504512
I tried to avoid gauss because i find it most fun when the solutions are my own. I guess I havent thought of something better yet so I might just do it like that. Thanks for the useful reply
>>
File: 1735467874847116.png (38 KB, 1009x158)
38 KB
38 KB PNG
I feel hollow.
>>
>2 more days
can't wait for this garbage year to be over
>>
>>107504547
>I tried to avoid gauss
Unfortunately (?) some AoC tasks are just constraint solving tasks, one that comes to mind is 2023 day 24. For that one, too, you can specialize using some linear algebra for that particular constraint system, by which you just create a solver for the specialized case. Or you can use a general solver.
>>
>>107504534
Thats a good observation, my guess is that it could require a lot of readjusting the buttons as you iterate but it is probably efficient still
>>
>>107504607
still you can only use this observation as a hint for heuristic for speeding up your brute force like solution. it's a waste to find a greedy approach
>>
File: 10.png (1.36 MB, 5440x6832)
1.36 MB
1.36 MB PNG
idiomatic Rust import solution
>>
File: 1758841778767969.png (17 KB, 398x126)
17 KB
17 KB PNG
I am getting filtered. BFS fails at part 2, too many branches to check. I understand Gaussian elimination solution but I lack finesse in Haskell to implement it. I think this should be trivial in Haskell if you know what you are doing since function manipulation is its forte. Whatever. I feel sad.

I am going to check if there is any linear equation solver library I can understand enough to use it. I've found one but it always generates solution going negative from 0, and it lacks any configuration, you just call the function.
>>
>>107505030
just use the simplex algorithm
>>
can some anon give a short explanation of what they mean by using bfs? i cannot conceptualize how something like that comes into play here. if you have links to like a blogpost or ytvid that works too
>>
>>107505089
Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next depth level.
>>
so I wanted to use bfs for part two, but then I ran out of ram
>>107505089
>pick a starting value
>generate all possible next step values
>discard all previously seen values
>go to step 1
>>
>>107505136
idgi :((
>>
File: Untitled.png (20 KB, 601x805)
20 KB
20 KB PNG
>>107505156
>>
>>107505089
>try all combinations of button presses if you may only press exactly one button
>try all combinations of button presses if you may only press exactly two buttons, by using the results of the previous step
>try all combinations of button presses if you may only press exactly three buttons, by using the results of the previous step
>...
>find a combination that gives the correct joltage
>immediately return current presses value
part 2 has lines with ten buttons and over 300 required presses though, which is almost 10^17 possibilities to check
>>
File: highs.png (19 KB, 325x240)
19 KB
19 KB PNG
kek, even the "import solution" solution is importing the solution by default
>>
>>107502120
I know what you are
>>
what if I tried dfs first? and sort the buttons, to first visit use the ones wired to the most counters.
and terminate early if any counter is already above the target
>>
>>107505136
of course you did. most of the lines in input contain joltage value upto 200. that means your tree will branch for 200 iterations. if the no. of switches is 4 then that would be 4^200 (pruning won't help too much here)
>>
>>107505239
What is the target though? If it is high you will lose a lot of time for a wrong guess
>>
>>107505282(me)
adding to this, anons why tf do you want to do bfs on the entire problem? reduce it using gauss-jordan
>>
>>107505354
explain gauss-jordan to a mathlet
>>
i wrote the code in my air jordans but it didnt help
>>
File: file.png (736 B, 69x30)
736 B
736 B PNG
>the joltage requirements are irrelevant and can be safely ignored
So I figured out what I will need to do in part 2, but question, will this part be used in it at all? I want to parse it to int bitmask for part 1 bui I don't want to fuck myself over into re-doing parsing and part 1 if it has any significance in p2
>>
>>107505385
no its not used
>>
>>107505385
Depends on the way you solve it, bitmasking doesnt carry over to pt2 well
>>
>>107505390
>>107505401
thanks
>>
>>107505401
>bitmasking doesnt carry over to pt2 well
it does though
>>
Would a time valid "solution" for p2 be to just solve the matrix with the given constraints using parametrized equations and check all the combinations?

In any case, EE bros i have been filtered. I wont implement my own matrix solver nor I will use a library. I have failed
>>
Man this day sucks. Pure math solutions are never fun.
Either import solution, already know some math trick, or make a butt ugly brute-forcer with arbitrary heuristics and hope it finishes within a day
>>
>>107505415
How? Cant think of a way they can
>>
>>107505372
if you're a mathlet you should already know this
>>
>>107505483
see >>107504852 line 42
>>
>>107505483
each bits tells you if any counter has to be incremented. kind of an and gate
>>
>>107505483
>take the theoretically largest possible number that can be submitted as solution
>mask all bits that aren't part of the correct answer
>left with bits that are part of the answer
>profit
>>
File: aoc_d_10.png (1.47 MB, 827x991)
1.47 MB
1.47 MB PNG
>be mathlet
>recognize p2 button counting means math.
>try dp anyway
>get btfo'd and google for np/scipy stuff until something works
The z3 stuff looks nice. I'll have to learn that. What was that previous years challenge where each button would increase a number? It might have been 2023.
>>
>>107505554
>What was that previous years challenge where each button would increase a number
You might be thinking of claw machine (day 13) from 2024, I don't recall anything similar in 2023. That was way simpler than this though because that had only two equations and two unknowns
>>
>>107505415
explain

>>107505450
you don't solve the matrix because most likely you will not get the required solution. you reduce the matrix into a reduced row echelon form. that will make it so that you have like 4 coefficients to satisfy for, like c0*x0 + c1+x1 + c2*x2 + c3*x3 = y. suppose you set an upper bound on the sum of presses on all switches to 400. then you can find all non-negative integer values of (x0, x1, x2, x3) such that the equation holds and the sum x0+x1+x2+x3 <= 400 (we want to use as little presses as possible and <= 400 at that). now after finding the x values for one row you can shift to the next row while preserving these x values and finding other x values x4, x5, etc. this way you will finding non-negative integer values of the entire x vector (x0, x1, x2, ...x(no. of lights - 1)). after that you sum this vector to get the no. of presses required. do this for a lot of different combinations of (x0, x1, ...) satisfying all the rows/equations and just take the min among all.

>>107505372
one search away anon. do you understand how you can rewrite this problem as a matrix equation Ax = b where b is the joltage array in {...} and A can be formed by taking the button configurations. so if there are 2 button configurations (2,5), (0,1,3) then A will have 6 (max value is 5 + 1) rows and 2 columns (2 buttons) like

[
[0, 1]
[0, 1]
[1, 0]
[0, 1]
[0, 0]
[1, 0]
]

RREF is just a reduced version of this matrix that makes a lot of values in it 0 so that the equation can be solved easily. but we only want the RREF, not the solution (that will not be non-negative integers)
>>
File: ?.png (373 KB, 750x1000)
373 KB
373 KB PNG
where bigboy
>>
>>107505571
Oh ya the claw machine! That was exactly it! Thanks!
>>
File: me_rn.jpg (14 KB, 250x250)
14 KB
14 KB JPG
EE here, first time I ever impoorted a solution. Part 1 took about an hour, part 2 about 5 hours.
After 3 hours or so I gave up on my "own" solution for part 2, forgot all the linear algebra shit from uni.
But I feel like having learnt how to use z3 is was a greater use of my time than re-remembering how to do Gaussian reduction or whatever it's called.
>part1: 300 µs
>part2: 85.7 s

P.s.: my broot from >>107493388 is still running
>>
>>107505519
>if you're a mathlet you should already know this
Wait does mathlet mean you can't do real math or you can do real math?
>>
File: filtered.png (59 KB, 1183x506)
59 KB
59 KB PNG
brutal
>>
>>107505652
mb i'm a retard somehow read that as mathlete
>>
this pipe welder is filtered, cya next year /g/
>>
File: 1548608624545.jpg (233 KB, 750x880)
233 KB
233 KB JPG
>stumbled through z3 solution
>works but I don't fully get it
I have my star but I'm as good as filtered.
Fuck math days. See you anons tomorrow.
>>
>>107505652
A mathlet can't do math, a mathlete however can.
>>
>>107505576
thank you for the thorough explanation
forgot so much math that I totally missed the echelon form. And the constraint is such an obvious idea but I didnt think of it too

>>107505635
based EE bro
>>
uhh brooters....

[/code]
Machine 58 (max joltage: 43): (Explored 3844570 states) 56 presses (1.62 s)
Machine 59 (max joltage: 44): (Explored 5000000 states) -1 presses (5.56 s)
Machine 60 (max joltage: 44): (Explored 5000000 states) -1 presses (6.47 s)
Machine 61 (max joltage: 44): (Explored 5000000 states) -1 presses (4.45 s)
Machine 62 (max joltage: 44): (Explored 300135 states) 44 presses (574.09 ms)
Machine 63 (max joltage: 44): (Explored 5000000 states) -1 presses (4.51 s)
Machine 64 (max joltage: 44): (Explored 5000000 states) -1 presses (5.23 s)
Machine 65 (max joltage: 45):
[/code]
>>
anyone tried using A* instead of brute after RREF? like anons are talking about BFS because we want to minimize the no. of presses. but this completely ignores the final state (joltages). what if we finding a heuristic function and explore those nodes that get us closer to this final state? I doubt a good heuristic function can be made though
>>
File: file.png (19 KB, 961x223)
19 KB
19 KB PNG
rustbros is there a terser way to type out this data for comparison?
>>
>>107505466
yeah this shit is awful
there should be some trick you can figure out to reduce the search space and make it brootable
fuck eric
>>
>>107505713
impl to-string for your parsed data and then just compare to the original string
>>
>>107505718
this anon did >>107504045
>>
>>107505745
>post guass
doesnt count
>>
>>107505757
wdym doesn't count?
>>
>>107505736
eugh, then the to-string needs to be tested too...
>>
advent of code has become advent of leetcode
>>
>>107505768
guass is the math trick that i dont want to have to know
>>
>>107505791
it's an algorithm. same as binary search, dijkstra's, BFS, DFS, etc
>>
>>107505806
dont care didnt ask
>>
>>107505791
>there has to be some trick
>n-no not that trick

be reasonable
>>
>>107505813
ah yes, the popular comeback among the "don't know what I am talking about" folk
>>
>>107505814
i meant a trick as in an observation you could make of the input, some kind of pattern or relationship between the buttons, etc. some optimization you can make that enables you to broot the answer
not some mathematical algorithm that solves 80% of the question
>>
>>107505814
lol. it's not even that difficult. and you only need some of it. I am a mathlet but I am only condoning it because I got it working.
>>
>>107505835
thread is so dead that this is what we're reduced to be talking about. atleast when the questions were easy the casuals kept it lively
>>
>>107505863
i dont see whats so weird about my statement, autismos are just being obtuse
its like the CRT question, while CRT is the easiest way to solve it if you know it, its not required to solve it. you can figure out a way to calculate the answer on your own
a question where you either know some obscure maths algorithm or import solution and theres no other option is fucking boring
>>
can't wait to get home from work and solve this bitch with Z3
>>
>>107499611
i'm reading the documentation, that's a sick language
>>
I knew it, I've done matrix math in Advent of Code before. 2023 day 24. I'm just going to copy paste that.
>>
I get the rough idea for part two, but realistic implementation is far away.
>>
>>107505882
you can't calculate the solution unless you know the math behind it and can solve systems with more variables than equations and then manage to minimize the solution with all the dependencies between the variables
>>
>>107505835
2/3 of cases in my input have less than 100 min presses
>>
Can you just binary search one possible solution a minute to any question without writing any code, since it tells you whether your answer was too low or high? What's stopping me from no-coding Advent of Code?
>>
>>107506093
might get you an answer, but not guaranteed to be the minimum number of button presses so its useless. some guy posted about it last thread
>>
today was a faggot puzzle for faggots, not doing it is actually how you win
>>
>>107506093
if you get close enough it stops telling you if you're too low or too high
also the amount of time between guesses goes up, I don't know how high
>>
>>107506187
10 minutes
>>
>>107506187
>>107506209
Oh, ok.
>>
File: z3.png (101 KB, 797x651)
101 KB
101 KB PNG
unfilter yourselves by importing solution to spite eric
>>
It's weird to see so many programmers hating on math. But I agree. Fuck math.
>>
File: izzat2.png (147 KB, 864x509)
147 KB
147 KB PNG
>>107506247
completing the puzzle is tacitly showing support for it. I instead refuse to finish it and will do other puzzles, showing my disapproval to eric
>>
>>107506269
I don't hate math, I am just not smart enough to do it.
>>
File: martlarb.png (157 KB, 1033x769)
157 KB
157 KB PNG
It's not an import solution if it's built in
>>
>>107506247
z3 Looks pretty nice.

Did anyone solve Part 1 with z3? I want to see what that looks like.
>>
Is today the day pychads? Is today the day rusteedees are eliminated and we live to py another day? Carpe diem pychads!
>>
any oldfags doing actual advent with their kids? man I loved that time. the last family would bake cookies for the next family at our school. and for some reason I just really liked the song. good times. anyways merry christmas boys!

https://www.youtube.com/watch?v=DkTWjhjKHjs
>>
>>107506366
multiple languages, including rust, have z3
>>
File: 10.png (1.21 MB, 2988x7496)
1.21 MB
1.21 MB PNG
mathlet friendly solution
>>
anyone broot this successfully over night?
>>
File: washed_ass.png (363 KB, 1108x766)
363 KB
363 KB PNG
>>107506247
Literally did same thing, but in another language

>>107506290
I KNEEL

>>107506366
I would use python more than I absolutely have to if it had braces and some sort of enforceable type-safety. Unbearable to do any project in Python that's >100 LOC.
As it stands, you can literally do shit like:
def func(x: int):
print(x)

func("retard")

And no, that's NOT a good thing.
>>
THE GREAT FILTER

(for yesterday)
>>
>>107506269
>It's weird to see so many programmers hating on math
For ages there has been a culture clash between mathematicians and programmers, it's nothing out of the ordinary.
Programmers prioritize getting shit done as clearly and efficiently as possible. If you lack a piece of knowledge, you find a quick rundown in plain english and build on it.
Mathematicians prioritize distilling logic into the fewest symbols possible, with zero regard for practical use, and no matter how much it obfuscates the meaning. If you lack a piece of knowledge, it's your fault for not spending years on dedicated math education. Go read a textbook until you can see beauty in all the dead alphabets.

Kind of funny how both fields depend on each other, but absolutely hate each other. Both are required to take part in the other to an extent, but usually aren't very good at it.
>>
watch and learn /g/
https://youtu.be/DZJKDmAwynE
>>
>>107506592
give code for this pretty pls, thinking of making it a little interactive
>>
>>107506449
my kid is not even crawling yet, just a limp poop & puke larva
>>
>>107505655
imagine getting filtered by import solution day
>>
>>107505713
why
>>
File: aoc2025-10.png (859 KB, 749x5731)
859 KB
859 KB PNG
Unwashed abomination
The original ran in ~10 minutes, plus I hardcoded one value which would have taken another 10 minutes to compute.
Current version runs in ~1 minute, after I realized you could subtract equations in some cases and get smaller equations that way.
I tried a few other things to optimize it but they just made it slower
>>
>>107506753
to import solution you gotta at least know what solution to import
>>
>>107503906
How do LLMs perform on these?
>>
>>107506781
who cares
>>
it's going to be import solution tomorrow as well, btw
>>
>>107506592
kind of underwhelming, i thought more people would've been knocked out by 9. it's not that many more than 8, which i assume was just attrition for people getting bored of doing this daily since day 8 was pretty easy
>>
>there are people in this thread RIGHT NOW that (rightfully) hate AI solutions, but imported z3
explain yourselves cowards
>>
>import z3
>import scipy
you did NOT solve it, you are FILTERED!
>>
I'm too bored to do part2 just to import solution
>>
can i still hang out in this thread if i got filtered? day 12 will be easy enough for me, r-right guys?
>>
>>107507040
>day 12 will be easy enough for me
You know what part 2 of the last day always is, right?
>>
>>107507040
Sure
>>
>>107507067
merry christmas and good night?
>>
Can I learn how to import solution in 2 hours? I am going to continue with my own solution when I get home, but ill bite the bullet and import solution if it is between that and being filtered.
>>
File: 1639185783346.jpg (82 KB, 650x580)
82 KB
82 KB JPG
>>107507040
if you can't even be fucked to ask ai for the z3 solution, then no
>>
>>107507117
i'd rather just not try than have to ask ai or copy someone elses solution
>>
>>107507093
it's basically just "you get this star if you have all other stars from this year". so skipping a star auto-filters you from final day part 2

maybe he wont do that this year though, in the past the final day has been christmas morning so he doesn't want to give people some ball buster on christmas eve/day. this year it's just a random friday so he could go all out if he wanted
>>
>>107506616
lol that's actually a pretty good take. most of the professional mathematicians I've met don't really do practical stuff. its usually like "oh right now I'm workin on knot theory and hopefully one day there's a practical application in medicine"
>>
>>107507111
brother if you want to cheat, just cheat, but don't cope about how you'll go back and do it the "right way" later
>>
File: 10.png (1.15 MB, 2962x6664)
1.15 MB
1.15 MB PNG
idiomatic Rust solution
takes only 100s for the input, but at least it's not import solution
>>
>>107506269
i enjoy any math that is up to like one half-step above what i did in high school. anything beyond that is annoying because i barely remember what little math i did in college
>>
>>107507117
Can't believe we've reduced ourselves to asking AI for Z3 code.. is that even programming??
>>
>>107506293
part 1 is for bitwise XOR
>>
>>107506962
My two stars say otherwise
Cope and seethe
>>
Eric baited me pretty good into finding a nice binary representation of the input and updating goal with bitwise ops for part1 - all useless.
>>
>>107507111
see: >>107506247

initialise variables to optimise e.g. `var = z3.Int(...)'
create an optimization context e.g. `opt = z3.Optimize()'
assert constraints
set objective to minimize e.g. `opt.minimize(...)'
run z3 e.g. `opt.check()' and check it returns `z3.sat'
extract solution e.g. `model = opt.model()' then sum `model[var].as_long()' for each var
>>
>>107507232
>>107507256
filtered
>>
>>107507227
>part 1 is for bitwise XOR
>>107507241
>Eric baited me pretty good into finding a nice binary representation of the input and updating goal with bitwise ops for part1 - all useless.
A binary operation puzzle for part 2 would have been awesome. I'm sure he's done it before too. But that must have been more than 2 years ago I think. Maybe in year you build that CPU?
>>
>>107507215
you could read the docs by "eric pony" (lol) yourself i guess if wasting even more time just to
import solution
in the end anyway helps you cope
>>
>>107507241
Same. I spent 20 of the 25 minutes I needed for part 1 parsing the lines into nice binary representations for BFS with XOR in C++. Then to my disappointment ended up making a separate Python file to import solution for part 2.
>>
>>107507263
yeah and? eric forced my hand
>>
>>107506938
>>107506962
I just don't like the puzzle is all
>>
>>107507241
yep, i did that too and felt proud of myself, thought i'd be setting myself up well for some "gotcha" in part 2 that would punish people who did it some other way. but nope, just toss your part 1 in the fucking trash for part 2 instead

kind of lazy that a third of the input is only used in part 1 and a third of the input is only used in part 2 as well. give us a cohesive puzzle ffs
>>
this puzzle is not in the spirit of christmas
>>
eric if you're in this thread... FUCK YOU
>>
>>107507315
He's sunk to stealing problems from advent of quanza.
>>
>>107507315
nobody is forcing you to import solution
>>
File: filtered.png (73 KB, 1473x630)
73 KB
73 KB PNG
absolutely brutal
>>
>>107507377
on the bright side, day 9 gold stars finally overtook the silvers
>>
gold
>your input is a list of numbers that correspond to evenly spaced notches around a circle, weave strings from one notch to the next then find the cut between any two notches that passes through the most strings
>also if you visualize it there's a picture and different inputs yield different pictures
mold
>here's an np hard problem, z3 it or die I guess
>>
>>107507377
>170k people completed day 1 part 1
>under 8k completed day 10 part 2
>>
>>107507363
i'm about to force something inside your body and you can bet it smells big
>>
some dude on plebbit brute forced part 2 in ruby over the course of 6 hours. what's your excuse?
>>
File: kot.jpg (104 KB, 740x895)
104 KB
104 KB JPG
>>107506938
z3 might come in handy as another tool in my toolset. Unlike the math that I learned in uni and then forgot.

>>107506962
>he did import solution
You did not solve it.

>he used math.h
You did not solve it.

>he used stdlib.h
You did not solve it.

>he downloaded gcc
You did not solve it.

You see where I'm going with it?
z3 is just another tool that you have to figure out how to use. It's not trivial, and learning how to quickly read up on documentation for an existing tool to begin using, instead of reinventing the wheel, is just as valuable of a skill as pure "puzzle" (read. math) solving.

I will broot and impoort as much as I like and I would still have solved it.
>No you wou-
don't care
>>
File: Untitled.png (157 KB, 450x450)
157 KB
157 KB PNG
>>107507377
>>
>>107507482
Copy and paste from reddit is just another tool I have to figure out how to use
>>
File: 1735056587784778.png (14 KB, 164x210)
14 KB
14 KB PNG
>>107505635
>>107505450
Finally managed to do it too EEbros. I should've chosen python instead of Haskell and just imported solution from. This was the worst puzzle of this year.

>>107505576
And many thanks anon. Your explanation finally made me understand what to do. I couldn't do it it in time without you.
>>
File: hmmm.jpg (57 KB, 700x700)
57 KB
57 KB JPG
>>107507490
Congratulations, you solved it!
But bigger question is, have you learned anything new?
>>
>>107507518
yes, i learned that i can be in the top 10 on the /g/derboard without knowing how to code
>>
>>107507482
this shit is not useful for the vast majority of developers and if you cannot come up with a bad but unique solution that finishes within a reasonable timeframe the puzzle is poorly designed.
a hacksaw and a file was pretty fine until today when you're asked to put a 5-axis cnc mill in your living room
>>
>>107506962
what about >>107506290 ?
>>
>>107507515
did you implement yourself the algorithm? nice EE bro
>>
>>107507576
then just don't do the puzzle. i don't understand why people write these epic rebuttals about how the puzzle is so dumb and stupid and irrelevant to real programming and then still feel like they "have to do it". nobody's got a gun to your head making you do this, because the truth is most puzzles are by design esoteric and irrelevant to real applications, but the thought of losing face on a mongolian basket weaving forum in front of maybe less than a hundred anonymous programming savants is too much for some people to bear.
>>
this year I decided not to do this to myself.
t. filtered on day 0
>>
>>107507666
>and then still feel like they "have to do it"
Getting starts releases dopamine.
Also checked, good point Satan.
>>
File: carbon.png (374 KB, 2048x1672)
374 KB
374 KB PNG
I wrote a "solution" to p2 that works by approximating the answer. I added some randomization to it such that I *sometimes* get the right answer on the test input.

But why the fuck am I not finding *any* result on the real inputs????
>>
>>107507482
>used math.h
>used stdlib.h
>downloaded gcc
The difference is that I could implement all of those myself without too much trouble mostly from memory (at least the parts of them I need for the problem). It would just take a while. Throwing constraints into a black box optimization function when I've never built one capable of solving this problem myself is different.
>>
>>107507730
"sometimes" getting the right answer on the tiny test input probably becomes "almost never" getting the right answer on the fuck huge real input
>>
>>107507749
So I'm not wondering why I'm not getting the right result from the real input.

I'm wondering why I don't get *any* result. In all its retardedness I really thought this would at least get me something.
>>
>>107503906
>get off work
>oh this looks like amphipods
>p1, easy
>p2
WHAT THE FUCK
>>
>>107507757
just do a dfs
>>
>>107507763
lol 8 hours so solve it before you're filtered
>>
>>107507769
this is sum fuckin bullshit nigga.
>>
>>107507766
but how deep do I need to go?
>>
>>107506764
why what
>>
>>107507743
lol what, it would be way easier to make some purpose build ILP solver capable of doing this problem than build a feature complete gcc drop-in. wouldn't be as optimized as z3 or scipy's versions but it's just a matter of knowing the formulas. it's just that doing so would take way longer and take more effort than would be worthwhile for this puzzle
>>
File: file.png (131 KB, 768x798)
131 KB
131 KB PNG
oh yea we be brootin
>>
>>107507779
8
>>
>>107507796
>feature complete
You don't need feature complete gcc to solve a puzzle though
It's pretty straightforward to make a compiler for enough of a subset of C to solve puzzles in
>>
>>107507815
printing way too much, gonna make shit even slower
>>
>>107507824
i doubt even that would be easier
>>
>>107507838
Maybe not but didn't everyone with a CS degree have to take a compilers class?
>>
>>107507815
>brootin with I/O spam
kek
>>
>>107505576
Im not sure how you created the matrix.
If we take the first example:
(3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}

the matrix should look like this?
[
[0,0,0,0,1,1] = [3]
[0,1,0,0,0,1] = [5]
[0,0,1,1,1,0] = [4]
[1,1,0,1,0,0] = [7]
]

and i dont get it how i get a RREF out of this.
>>
>>107507763
import solution day don't even bother with this low quality puzzle
>>
>>107507815
If you're printing more than once a second or so you're throwing away performance
>>
>>107507863
filtered
>>
can you think of a shittier problem for the last two days? this one's hard to top (not because it's hard)
>>
>>107507827
>>107507870
>>107507896
the more it takes the better
im on my 3rd line now
>>
File: code.png (223 KB, 1468x1402)
223 KB
223 KB PNG
z3 and python
ngl this feels like cheating
>>
>>107507663
I had to mangle a bfs function terribly to achieve what I wanted but it worked. I used conditions from row echelon form to prune branches. I should've implemented my own bfs instead of using one from a library, but I wasn't feeling competent enough. Now I think I can write one though, which is nice.

Times like this make me miss matlab
>>
>>107507923
https://adventofcode.com/2023/day/25
>>
>>107507666
i'm not doing it, i would have wanted to do a day 10, that's the point. now i get a gap because eric threw in a razor dildo only a select few number crunch autists have the background to enjoy.
>>
>>107507943
Ah, another import solution day.
Or rather, just shove it in graphviz and look at what connections to cut.
>>
>>107507932
holy based
>>
>>107507932
Can't argue with that logic. Best of luck
>>
>>107507666
> but the thought of losing face on a mongolian basket weaving forum in front of maybe less than a hundred anonymous programming savants is too much for some people to bear.

Couldn’t be me
>>
>>107507943
to be fair, you can do max flow min cut without import solution...
>>
>>107507666
it's really satisfying to bitch, OK? I'm not doing it this year but I've done it to excess.
a guy with these digits should get that.
>>
>>107507969
Or use annealing + visualization that supports zoom and rotation to find those labels, all in Javascript and no libraries.
https://i.4cdn.org/wsg/1765399528204905.webm
>>
>>107508059
Hyper based. Reminds me of how programming is done in Diamond Age
>>
File: overlay-image.png (71 KB, 250x140)
71 KB
71 KB PNG
>>107507941
impressive, i might give it a try this weekend, thanks for sharing your success
i too sometimes miss my matlab scripts for analyzing ffts and do basic signal processing, and simulink too ofc. but matlab syntaxis sucks ass
>>
>>107507407
>170k people completed day 1 part 1
I was one of them. d1p2 was already too much of a hassle for me.
>>
>>107507969
my p1 graph:
let graph m =
let g = G.create () in
for i = 0 to limit m do
for b = 0 to Array.length m.buttons - 1 do
G.add_edge_e g (G.E.create i b (push m b i))
done
done;
g

vertex: every single possible state up to the next power of 2 above max bit set by any button
edges: every button pressed on every vertex
shove that into shortest_path, quick enough answer.

similar logic in p2 (limit: every joltage that doesn't exceed any joltage goal) doesn't get me past building the graph for the first problem
I can definitely do this in a smarter way, my point is that solving it by visually cutting edges in a graph still has some impressive prerequisites
>>
>>107506892
>kind of underwhelming
yeah, it was more impressive at 18h
>>107506709
In the archive I put the "original_script" directory I have, the current modifed python script I use and the wrapper script to fetch the json files of the leaderboards, merge them, save them, call the python script. All you need to do is put your session cookie in the script and do ./tgf.pl --get. You problably need to install cpan and install a handful of modules too.

https://desuarchive.org/g/search/text/dhKRnYkj/
https://desuarchive.org/g/search/text/rPHzCBAS/
https://pastebin.com/dhKRnYkj
https://pastebin.com/rPHzCBAS
https://files.catbox.moe/rzo2hk.zip
>>
>>107508059
How does this work?
You pull nodes closer to their neighbors and apart from their non-neighbors?
>>
>>107508125
tiny mistake about tzset()'s error handling, wrong error variable
https://files.catbox.moe/1qicas.zip
>>
File: carbon(1).png (314 KB, 2048x1224)
314 KB
314 KB PNG
>>107507820
Okay, what now?
It works for the test input, but doesn't for the real input.
>>
>>107508192
By that I mean that it gets the good result for the test input, but with the real input, while it gets a result, it gets the wrong result.
>>
>>107508081
Thanks!
This is the code, it also records a video of the simulated annealing. It starts by pressing key r, and stops recording when is cold enough. Zoom using the wheel and rotate by dragging.
https://jsfiddle.net/2pxewgL0/
>>107508179
All nodes repel, connected nodes attack each other, and the amount goes down in time.
>>
>>107508125
>archaic, unreadable perl script does 400 lines of something before calling python script

Christ. Someone should really redo this...
Anyway, thanks anon!
>>
>>107508237
Attract
>>
>>107507937
oh it *feels* like cheating huh?
>>
>>107508119
day 1 pt 2 was the real filter /gen. still recovering on like 2 leaderboards from points back then
>>
When was the last time you implemented a LP solver from scratch for actual work (not homework assignment or programming puzzle)?
>>
>>107508248
>archaic, unreadable perl script
based
>calling python
WHAT IS THIS SHIT ANON, WHAT ARE YOU DOING
>>
>>107508298
no employed pipo solve aoc, first of all
>>
>>107508298
The amount of people who work professionally on problems that require LP is vanishingly small to the total coding population.
>>
I'm back to y2019d12.
The large example fails, it gives me incorrect answer. I'm trying to find period of each planet separately, and then compute lcm of all periods. Works good on small input.
Does it fit in int64?
>>
>>107508369
>million lines of puzzle text
>problem sounds interesting

the world you grew up in no longer exists, you WILL import solution
>>
I read part2 like 10 times...
Eric I....
>>
>>107508423
are you sure you read it enough times? I was still thrown a loop by assuming that some p1 conditions continued into p2
>>
>1 anon posts niche LP solver solution
>rest of the board pretends like they figured it out too
kek.
>>
>>107508328
Even if you require LP professionally, you will most likely use a library anyway.
>>
>>107508444
I read it... I solved the "example" and then the existential dread of how big this problem is set in.
>>
>>107508453
Link?
>>
File: pyslop.png (70 KB, 783x746)
70 KB
70 KB PNG
>>107503926
I went looking for alternatives to this, and after recommending some hallucinations, slop settled on python
>>
>>107508453
>optimizelet couldn't figure out the LP approach on his own

Lol
>>
>>107508248
Im at work and still have 7 hours. Fuck you
>>
>>107508248
>archaic, unreadable perl script does 400 lines of something
I had to rewrite it this year, but it's pretty solid. In my version I have a few less function declarations because they are in modules of mine.

also matplotlib is broken now, there should be black surrounding the graph and a title like in pic rel.
it looks fugly and broken so I modify it with an image editor, pick the dark blue color and fill the white background with the dark blue. Come to think of it should maybe be black like in the original.

2 years ago? I tried to modify it for the final version. Put a snowflake instead of a red dot for the winners and use a color gradient from grey to white for the curvy lines. White being at the top for the non filtered. I spent hours reproducing a reproducing the image of a new snowflake I've found, using a bit of trigonometry, but it rendered like shit in matplotlib. I tried to reproduce the entire graph in an old perl 2d graphic library and it was even worse. Next idea is to make it in C and use OpenGL. That will be as solid as it gets.
>>
*neat snowflake
>>
>>107508453
There's an optimization or constraint satisfaction problem almost every year
It's not hard to make the connection to use a solver when the problem statement contains the word "fewest"
>>
>>107507943
why can't this be brooted?
>>
>(nor can you push a button a negative number of times)
basically confirms the intended solution is math, you'd never get that with a non-math approach
fucker
>>
>>107508797
if wonder if pannenkoek2012 found a 0.5x A press solution
>>
File: 1730123622041249.jpg (10 KB, 201x244)
10 KB
10 KB JPG
>>107506290
Bravo to you EEchad
>>
I refuse to import or implement a solver

my idea for a solution was to find the max possible quantity for each button group and then iterate over all combinations, discarding when further increments would always fail e.x.

(0, 1) (1) {3, 4}

(0,1) can be pressed a maximum of 3 times, a 4th press would exceed position 0
(1) can be pressed a maximum of 4 times

max: [3, 4]

now iterate through all combinations up to max looking for results that equal {3, 4}
[0, 0] -> [0, 1] -> [0, 2] -> [0, 3] -> [0, 4]
>no matches
[1, 0] -> [1, 1] -> [1, 2] -> [1, 3] -> [1, 4]
>[1,4] exceeds target, stop early
[2, 0] -> [2, 1] -> [2, 2] -> [2, 3] -> [2, 4]
>[2,3] exceeds target, stop early
[3, 0] -> [3, 1] -> [3, 2] -> [3, 3] -> [3, 4]
>[3,1] result found
>[3,2] exceeds target, stop early

however I have a feeling even like this the brute will just take too long. any feedback for further optimizations or if someone implemented it in a similar way and it didn't take that long? I have no interest in solving this problem the math way so I'd prefer to just not do part 2 if it looks hopeless
>>
>>107508876
I implemented something similar to this, and if my solution isn't somehow the most inefficient thing ever, it took way too long.
I'm stuck trying to figure out any other solution, also.
>>
>>107508543
>>107508248
you now understand the commented "$day--;" line
>>
>>107508797
Also remember the no fractions sentence. It clearly hinted to Integer Linear Programming (k^n), even harder than regular Linear Programming(n^k).
>>
>>107508453
This is so brown-coded. You're so used to copying from each other that you can scarcely conceive the possibility of men indepently coming up with solutions using their own work.
>>
>>107508876
Anon, even with Linear programming, and because the solution must be an integer, you need to check integer numbers close to the solution. That alone makes it O(2^n) where n is the number of variables.
>>
>>107508876
Wow that's a simple but clever idea. I wonder if that reduces it by enough to DP. In the pure dp memoized version we're already keeping track of if an individual slot exceeds the target... so it might not reduce it by enough. Maybe you could do some binary search optimization thing where instead of only between 0 and the max value at each step and then no further increases? But its still pretty iffy.
>>
>>107508876
that's what I did and it solves the example problems very quickly, but then takes forever on even the very first input. And the joltages in the input go up to >256
my thought was DFS with a cache instead of building a complete graph to BFS
>>
File: carbon.png (123 KB, 691x754)
123 KB
123 KB PNG
>>107505554
I used Z3 for that one too >>103501759 and everyone in the thread bullied me.
>>
>>107505554
2014 day 17
>>
File: 1745801199366791.png (647 KB, 1874x3426)
647 KB
647 KB PNG
Linear algebra? Constraint solver? What the fuck are you people talking about?
$ time pypy3 10.py < input
Gold: 20083

real 172m31,061s
user 171m8,356s
sys 0m2,403s
>>
>>107508248
>Christ. Someone should really redo this...
>>107508568
If you don't mind, can I add in a feature to it? I want some historical data. Being able to track the instances of anon's position in a board at a certain time could be really funny to see.
>>
>>107509098
>>107509098
>If you don't mind, can I add in a feature to it?
Go ahead anon. I'm not the author of the original python script btw.
>>
>>107507661
SOVL that bypasses all filters
>>
>>107509092
I KNEEL. Mine is running now. So many cheaters itt
>>
fuuuuuuuck this sucked
>>
File: 136.jpg (26 KB, 500x366)
26 KB
26 KB JPG
>>107506449
Yeah they all got Lego advent calendars
This puzzle sucked as a non compsci retard. Never went past calc. P1 was braindead search but p2 I knew it was going to be some sort of linear system but…that’s too many words for filtered.
Fuck you eric and your Chinese remainder faggotry
Was there an intuitive solve that didn’t rely on scipy or z3?
>>
>>107509198
holy
>>
>>107509073
That's some nice z3'ing. Thanks for posting that I really gotta switch to that for puzzles like this.
>>
File: file.png (48 KB, 973x413)
48 KB
48 KB PNG
so is there a good solution without using ILP?
I reworked my heuristic and restarted, Im back on line 3
>>
>>107509092
HOLY SHIT I KNEEL
>>
>>107509092
>pypy
>compiling your code instead of making your computer interpret every line of code every time

You call this brute force?
>>
>>107509198
>awk
How did you do it?
>>
>>107509198
holy mother of based
>>
>>107509326
Surprisingly not too complicated, it was just a bitch for me to figure out because I'm kinda retarded.

AWK has native hash tables, so in part 1 I used an expanding hash table with each light state as a key and the did a basic BFS. But part 2 caused the table to blow up and I wanted to at least try to do the big boy so I did the matrix math solution instead.
>>
File: file.png (30 KB, 452x409)
30 KB
30 KB PNG
>>107509238
time to go to sleep
>>
>>107508248
>https://pastebin.com/H0qajEyC
Yes! Not filtered yet! Update your filter chart, John Doe is through!
Took forever to solve, and I had no time to work on it during work.
>>
>>107509437
That's not the official one, relax. Look at the white border and lack of title etc.
>>
>>107504045
>>107509437
Thank you C-chad for this. Gave me the final push I needed to implement my own solver instead of import solution.
t. John doe
>>
Technology?
>>
File: nghhh.jpg (20 KB, 363x364)
20 KB
20 KB JPG
I think this is it
this might be my filter
>>
>off by 1
>>
>>107509523
I went looking for my z3 code from last year and found that I never wrote any. I completely forgot that I'd been filtered.
>>
Honestly, this was a boring fucking day. I hate implementing linear algebra solutions. The theory is clear, easy, and it is so easy to do a single mistake somewhere and have it all come crashing down. I haven't looked at this shit since uni and I didn't like it back then either.
>>
>>107509565
midwits will seethe when they read this
>>
I'm sorry /g/, this time I resorted to import solution.
>>
>>107509565
>I hate implementing linear algebra solutions.
Yeah, real unfun grind time tracking down all the little bugs.
>>
>>107509639
Yep, and not only that, but you have to type out lots of code compared to what you are actually doing.
>>
>>107507666
>let people enjoy things!!!
no?
>>
>>107508248
now that's a nice filter
>>
>>107508369
>does it fit int64
jesus christ you ask this every day
>>
>>107508876
i don't think this is really much more efficient from just doing BFS but killing a path if you exceeded the numbers. it's not gonna help that much when you have 6 joltage numbers that are all over 100
>>
>>107508369
Every day of every year fit in an uint64, except for y2022d22 where you will need a 128 bit int.
Slam shuffle, man, slam shuffle.
>>
no bigboy today because it just doesnt make sense?
>>
running part 2. 5/167. This better work, I am out of ideas.

I will NEVER import z3 btw. ID RATHER BE FILTERED WITH DIGNITY. YOU ARE ALL SPINELESS COWARDS. STAND AND FIGHT
>>
>>107509791
Just do the linalg. You don't need a library for that. I didn't want to do it either, but I relented. Takes forever, boring, horrible, but when all is said and done it's not worth it but at least you aren't importing solution.
>>
>>107509791
i don't respect this puzzle so i don't mind cheesing it. if the linear algebra shit was just one aspect of a more involved puzzle, then maybe i'd be interested in solving it "for real", but the puzzle is literally just "do this math problem" and nothing more so fuck it
>>
>>107509791
Just join the importer team, I wasted so much time building my own solver and it didn't even work.
>>
In a way this puzzle was very much like those MD5 puzzles in 2015 and 2016
>>
>>107509805
I haven't looked at any solutions because I'm not cheating.

I don't understand how to use linalg as I don't think the buttons are linearly independant?
>>
File: aoc10_badbrute.png (584 KB, 1280x5066)
584 KB
584 KB PNG
despite my best efforts the brute did not finish or even find a single solution
I have tried so much reordering of the search and various cheeky early exits to prune the tree
but I just dont know what to do with the crazy high jolt counts

are we sure this is not just the knapsack problem
I need sleep anyways so that is it for me until the next puzzle drops
>>
>>107509819
this is the most pathetic cope I ever read.
>I can quit any time I want
level cope
>>
>>107509791
This is the first year I actually bothered with z3. But now I am writing my own implementation of Gaussian elimination.

I took linear algebra over twenty years ago. I need the refresher.
>>
>>107509879
think whatever you want, i got the star :)
>>
>>107509881
I dont get it

Like when you zero out the first column, you cant be greedy and use a single button, you could use any combination of buttons with a 0 in them. I don't see how linear algebra simplifies this.
>>
File: file.png (521 KB, 827x1256)
521 KB
521 KB PNG
I am (anonymous user #2323159). Put me as filtered. I refused to import the solution, but I'm too stupid to understand how to implement it.
I am posting this as a surrender point. Bedtime is in 30 minutes and I'm nowhere closer to the solution.
I will read up on the topic though, thank you >>107501165.
>>
>>107509861
I took an advanced course in linear algebra ages ago where we were taught alot about cryptography and under specified systems. Basically, there will be a mixture here between pivot vars and free vars, and if you do a gauss elimination you will be able to identify which are which, and then you can vary the free vars within a search space.
>>
>>107509409
I have some good news and some bad news
Good news is I think it finished
Bad news is Im not getting display output and I didn't pipe the output to a file
>>
>>107510020
Like I understand that you can make buttons out of other buttons (ie free vars), but I don't understand how this preserves the "Minimum button press" rule. would doing row operations fuck up the buttons and not preserve this? and couldnt the free vars be used in the minimum button solution still?
>>
File: aoc-day-10-sloppa.jpg (1004 KB, 1408x768)
1004 KB
1004 KB JPG
daily sloppa ft. >>107509791
>>
>>107510030
simply epic
>>
>>107510101
>i'd rather die filtered
COPE
>>
fuck this, I'm not writing my own integer programming solver
>>
>>107510079
You get a fixed number of presses from your pivot elements, and when you add all those up you'll find yourself some presses short from the free buttons to reach the target. And then you vary the free buttons until you find a minimum. Basically. Try a gauss and print out the matrix and you'll start to see it.
>>
>>107510101
slopsovl
>>
>>107510101
>ericpony made it in
based
>>
File: d10.png (140 KB, 762x1038)
140 KB
140 KB PNG
Ok, I'm filtered. Part 1 was nice. I know Part 2 is linear algebra / linear programming, and I can't do it without copying an algorithm or importing solution.
>>
>>107510157
I thought this originally, but i don't see how most input lines have any good pivot buttons, so many have like 10 buttons that have 9 elements overlap. How do you choose a pivot element? Isn't that a greedy algo that doesnt work?
>>
>>107510395
like consider the case with buttons (0,1) (0,2)

| 1 1 0 |
| 1 0 1 |

Sure I can subtract row 1 from row 2 to reduce the matrix to
| 1 1 0 |
| 0 -1 1 |

and solve the system of equations from that or whatever. But now I have a row that represents pressing button 0 and..... unpressing button 1 ??????? How do you tally total button presses from that. How does a solution generated from the reduced form ensure the button presses are minimized.
>>
>>107510527
all of a sudden the thread of """""Not Filtered""""" anons have nothing to say. ITS ALMOST LIKE IMPORTING Z3 IS CHEATING
>>
>>107510527
you brute on this reduced problem. as simple as
brute means try different integer values for different columns and see if it matches the rhs. except now you have a very small no. of params like 4
>>
>>107510527
Your matrix is transposed, it should by 3 rows 2 colums. And matrix should be 3xN where N > 3. There needs to be more buttons than there are joltages, because if there's fewer, you can at most have only 1 very specific solution that's very dependent on input.
>>
File: 1632977808608.jpg (71 KB, 444x333)
71 KB
71 KB JPG
Filtered is a state of mind
>>
>>107510527
>>107510569
>>107510651
mathlet here, i can understand the left side of the "system of equations" shit where the coefficient is the number of times you press the button. but i don't understand the right side. are those also variables with coefficients?
>>
>>107510527
It won't be minimized. In fact the step to go from a best solution (over real numbers) to one constrained to integers is the tricky part for even the automated solvers, and the ability to handle this part is often what separates strong solvers from weaker ones. Men with PhDs have dumped years of their lives to make things like Gurobi fast, since as the number of variables increases that becomes difficult.

Anyways, you just have to recognize it as a place to start your seach.
>>
>>107510569
won't work, you'll end up with fractional button presses. "An A press is an A press, it can't be half"
>>
>>107510704
You're solving mx=b for x.

m is your button-sets (column-wise),
x is a vector, with each digit represting the button pushes for the corrosponding button-set.

b is your goal state, what you're given in the problem.

So you're finding a linear combination of the button-sets to equal the goal b.
>>
>>107510739
ok so what does a row represent once you do elimination and subtract rows from eachother. negative button presses? It makes no sense.
>>
>>107510752
The same as before, because those row operations yield an equivalent system of equations.

To be honest though, I wouldn't continue down this road if I were you. Even when you "solve" for the x, you're still going to have negatives, and rational numbers that you need to "get rid of". It's going to be much, much easier to just use a solver like z3.
>>
>>107510706
I know, it was just an illustration of subtracting rows.

What i mean is lets say i do reduce it to reduced row form vectors v1,v2,...vN.

And i solve for coefficients b1,b2....bN

That is simple enough, but now vector v1 represents something like (5 presses of button 3, -3 presses of button 2, 3 presses of button 8, -7 presses of button 1)

Because I subtracted rows when reducing. And you cant unpress buttons so I don't see how that solution is valid, or minimal for button presses for that matter.
>>
>>107510776
>I put it into claude code and got the answer what is the problem
This is how you sound.
>>
>>107510828
Get filtered retard.
>>
>>107510839
According to you im not filtered as I have my star from z3
>>
>>107510891
copied from AI btw.
>>
>>107510704
Ax = b
upper case is matrix, lower are vectors
x is a vector of unknowns that you have to solve for. swapping rows does nothing because it's just like writing the equations in a different order. if you have a few equations then the solution of this system of equations aatisfies them all individually. the order in which you write the equations is meaningless.

similarly doing an operation like row a := row a + k*row b. think of it like this. if you have 4x=8 and 3x=6 two equations then if you multiply one equation by k then the eqn will stull hold so 4kx=8k. now you can add/subtract the same value from both sides of an equation too. so 3x + z = 6 + z is will hold.
now we can just do 3x + 4kx = 6 + 8k because 4kx = 8k. so you see these two operations of swapping rows and adding/subtracting a row times k from another row does not change the sustem of equations. the solution set remains the same. we are only doing it to make solving the system convenient. after reducing it to a reduced row echelon form the last row will have a lot of 0s followed by some non zeros. this is what we want. we want a row to contain as many 0s as possible so that we only have to brute for the few non 0s.

suppose you have a0*x0 + a1*x1 ... an*xn = y and a lot of values a0, a1, a2 are 0s then we only need to brute for different integer values of x3, x4, ..., xk to see if the equality still holds or not. once you find the xs for last row you can move to an upper row while persisting the x values already found. now you will have a few more free variables because the upper row will not have as many zeroes. this way you solve for each row. then you assing min steps := min(min steps, curr stepa). then you backtrack and try some other combination of xs that solve the equations. dfs will help here since backtracking is implicit.

honestly just watch one video on it if text is intimidating
>>
Verbose z3 fraud.
>>
>>107510973
thanks, still don't get it 100% but this added some helpful context to stuff i'd read elsewhere
>>
>>107510651
NTA but I tried this and it takes forever. Maybe there is a faster way to brute that I'm missing.
>>
>>107511063
there's a C solution somewhere above that cuts down on the solutions you have to check for since any key can only be pressed some max X number of times, runs in reasonable time
>>
>>107511119
this is in my broot and it didnt help because enough of the button sets look like (0 2 3 4) (1 2 3 4) (0 1 3 4) (0 1 2 3)
>>
>>107511063
mine takes a long time too. you have to use heuristics to reduce the search space.
1. put a limit on how much sum can be. that way you don't need to try 0 to 1000 for each variable.
2. prune the paths if it leads to more sum than the current known minimum
3. instead of putting a limit once like 350, you can do it incrementally. so first out a limit of 100 and then do a full run. only if a solution is not found then do 200. and so on. since it will be very fast for smaller sums. and 2/3 of the cases will have less than 100 ans in my input

after this you can just multithread the shit out of this since all the cases/lines are independent and only sum needs to be calculated

>>107511134
this is blind broot. it's hopeless without the jordans
>>
THE GREAT FILTER
>>
someone make the new thread so I can beg people to join my attempt at a summer version of this thing because I like spending time with you guys
>>
new thread

>>107511264
>>107511264
>>107511264

new thread



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.