new puzzle challenge
|
04-04-2015, 12:48 PM
(This post was last modified: 04-05-2015 02:37 AM by Claudio L..)
Post: #29
|
|||
|
|||
RE: new puzzle challenge
(04-03-2015 08:43 PM)PANAMATIK Wrote: Perhaps you are aware, perhaps not, that many other members or nonmembers are reading this thread with great pleasure, seeing your efforts and results, without being able to participate in these kind of mathematics games, but admiring it. I'm one of these quiet readers and want to congratulate any of you in advance for finding all the n-th order solution eggs. Thanks for the encouragement. You shall be rewarded with the full source code: For proper code optimization, this is the variable numbering (quite strange for humans, but optimized for the machine: Code:
A trough L are the outer ring, where we can write the first 6 equations with only 3 letters each, and completely decoupled from the rest. This allows to solve for the first 6 variables out of seven. As explained in my previous post, the code walks the perimeter setting a number for A, then trying all values of B knowing A+B>=19, and computing C per the corresponding equation C=38-(A+B). This is done by this code: Code:
M is the 7th independent variable. Once the outer ring is known, trying all possible values for M allows to calculate all letters N through R in the "inner ring" by using the 4-term equations. N=38-(B+M+F) O=38-(D+N+H) ... The inner ring code expects to find already on the stack the 12 variables A through L with L on level 1. The inner ring is solved by this code: Code:
Finally, we need to do the proper checks with the center value (last position, S). All we have to do is find the only number that was not taken in the stack and check all 3 equations with 5-terms. This is done here: Code:
And to wrap it all up, the code above needs a couple of things to run properly:
This is done here: Code:
For the short of patience, partial tests can be ran, if you put a partial list of numbers (must be a valid partial solution, of course), and run the DOLOOP test to see if any solutions are found. Just make sure 'SOLUTIONS' contains an empty list and that there's nothing else in the stack but your partial solution. The partial solution has to contain 1, 3, 5... elements. In other words, think of the corners as the independent variables, then to give 2 independent variables you must also provide the intermediate value between them (A, B and C). This is tested and finds all 12 solutions, but of course I tested it on a PC with newRPL, don't have the patience to wait 19 hours, but if somebody does, please measure time and report here. Happy coding. PS: Still not a one-line RPL solution... but faster than my first try at 97 days! EDIT: Forgot to mention, if you don't wait to wait 19 hours, and don't care about the different rotations, you can get a nice solution by doing: Code: { } 'SOLUTIONS' STO 3 DOLOOP This will leave SOLUTIONS with all solutions that have a 3 in the first variable: exactly 2 solutions, one mirror of the other, and only for about 1 hr of your time. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)