HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
|
09-12-2022, 08:30 PM
(This post was last modified: 09-12-2022 08:33 PM by C.Ret.)
Post: #25
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Ha, Ha !
I finally and not without difficulty, succeeded in adapting my code to the rules of the game. I used an algorithmic shortcut which made it stop when the user entered a palindromic integer. I thought I was going crazy; I turned like a fool any subsets of my code in all the directions and , the only versions that worked by correctly applying the rule were too long, too slow too complex. It is only in the evening that I had the idea of using the user flag FLG 00 and I was able to adapt my original version cheaply. The code I obtained is very similar to Werner's, at least in its operating principle. On the other hand, the calculations made and the registers used have nothing comparable. In fact, it is greatly different in the details and a bit longer code: 51 bytes (without global alpha LaBeL and END), three registers and a flag. (09-12-2022 01:51 PM)Werner Wrote: My first try, 41-compatible, needs 1 register (00 here) Good code, I need to study how the NUMBER INVERSION procedure works; the percent % statement piques my curiosity. On the other hand, I don't see anywhere where the control of the maximum number of loops or the detection of the maximum capacity of ten digits is done?!? My code is 10 bytes longer, but it does all the due checks and it returns Y:0 X:0 on overflow digit capacity or loop number. Code: 001 STO 01 SF 00 51 STO 02 0 STO 03 @ R01:actual integer R02:cycles limit R03:addition's counter Well, I haven't found any integers that approach the 50 iterations limit without exceeding the 10 digits limit! Besides, I had a hard time finding an integer that don't give a palindrome in a few turns of the wheel! Sadly, the main part of all the integers I try have a tendency to rapidly form a palindrome. At least 196 works! P.S.1: Attention, in case of overflow, my code resets all the registers to zero. I'm a lazy person who doesn't try to preserve anything and finds it fine to use CLRGs shorter than 0 STO 03 STO 01. P.S.2: The printed version contains on step 31 a VIEW 01 to see what is happening and on step 41 a TONE 5 to sound the end of the race. These two statements are optional. If I could have been present at HHC 2022, they would not have appeared on the copy I would have given to the jury. Thanks for sharing this. I had a lot of fun developing my code on my old, robust and reliable HP-41C |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)