Comment on Who's up for a challenge?
e0qdk@kbin.social 9 months ago
If I understand the problem correctly, this is the solution:
::: spoiler solution
a = 2299200278
b = 2929959606
c = 2585800174
d = 3584110397
:::
I solved it with Z3. Took less than a second of computer time, and about an hour of my time -- mostly spent trying to remember how the heck to use Z3 and then a little time debugging my initial program.
ExLisper@linux.community 9 months ago
Yep, that’s correct. I never heard about Z3 and I did it by reverting all the operation. It takes couple of seconds of computer time to solve my way but it took me closer to 7h to figure it out. 1h is impressive.
There are actually two possible solutions because some bits are lost when generating numbers. Can Z3 account for lost bits? Did it come up with just one solution?
e0qdk@kbin.social 9 months ago
It gave me just one solution the way I asked for it. With additional constraints added to exclude the original solution, it also gives me a second solution -- but the solution it produces is peculiar to my implementation and does not match your implementation. If you implemented exactly how the bits are supposed to end up in the result, you could probably find any other solutions that exist correctly, but I just did it in a quick and dirty way.
This is (with a little clean up) what my code looked like:
::: spoiler solver code
#!/usr/bin/env python3
:::
If you're not familiar with SMT solvers, they are a useful tool to have in your toolbox. Here are some links that may be of interest:
ExLisper@linux.community 9 months ago
I think that’s the issue, in the second possible solution one of the parameters is negative :)
This looks great, I didn’t even know it’s possible to solve it this way. I’m glad someone dedicated some time to it. Let’s see if anyone will try solving it in other way.