Puzzle - RPL and others
|
04-29-2021, 07:03 PM
(This post was last modified: 04-29-2021 07:12 PM by Allen.)
Post: #22
|
|||
|
|||
RE: Puzzle - RPL and others
(04-29-2021 05:16 PM)Albert Chan Wrote: How does the code work ? In having fun with different ways to calculate the final SSN, I wanted to play around with as simiple an inner loop as possible. Here's a more simplified 46-byte solution that's a smaller, faster, and clearer Code:
If you take the central part of this code: Code:
it assembles (left to right) a number that is divisible by the numbers 3 through 9. Unfortunately the naive way produces a number that is not pan-digital. Python Example here: Code:
With a few small corrections during the process one can trick the calculator to produce correct results using the naive algorithm: Code:
(04-29-2021 05:16 PM)Albert Chan Wrote: Where does the cubic, 19x³ - 9x² - 27x, comes from ? In my initial larger version, I was looking for a correction factor for the naive approach to make the number pandigital without modifying the actual structure of the program. 381654729 - 321252489 = 60402240 As it turns out, adding the results of the polynomial 19x³ - 9x² - 27x for 2<x<10 was within 18 of the final answer. The rest of the rube-goldberg looking code is byte savings by reusing the constants {-27,-9,19} to either initialize variables, create coefficients, or implement the final offset (+18). 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)