HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
|
09-12-2022, 02:53 PM
Post: #21
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Here is a version for the HP-28 and 48 only, it would need to be modified for the HP 49/50 because of decimal points in approximate numbers.
Code:
It calls the following program NREV which reverses the digits of an integer. Code:
|
|||
09-12-2022, 03:15 PM
Post: #22
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
An illicit non-entry for the 33s, probably faster than 50g User programmes:
Code: 1. LBL C |
|||
09-12-2022, 03:17 PM
(This post was last modified: 09-12-2022 03:19 PM by Gerald H.)
Post: #23
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
A possibly licit entry for 50g but is more verbose than allowed by rules:
Code: Size: 153.50 |
|||
09-12-2022, 08:03 PM
Post: #24
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-12-2022 12:49 PM)3298 Wrote: This part is a subprogram because it's used in two places: adding the reversed onto the original, and checking for a palindrome (the latter is implemented as an equality check between reversed and original). Same idea. Better keep the program in one piece, like you did, even though the length increases by some 10% (# 559Ah, 221 bytes). Code: « R→I -105 CF 0 SWAP |
|||
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 [attachment=11099] 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 |
|||
09-12-2022, 09:01 PM
(This post was last modified: 09-12-2022 09:02 PM by Craig Bladow.)
Post: #26
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Here is my entry that won the RPN part of the HHC 2022 programming contest this year. It is 76 bytes long. CLS is the raw file decoder's output for the command that clears the statistics registers. Likewise '#' is not equals.
Code:
Try CC41! |
|||
09-13-2022, 07:46 AM
Post: #27
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-12-2022 08:30 PM)C.Ret Wrote: 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?!? I missed that in the problem description.. Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
09-13-2022, 11:28 AM
(This post was last modified: 09-15-2022 10:50 PM by Gene.)
Post: #28
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
FYI - the intent was to not use sysrpl and not use any sysevals or flashevals.
The "feel" of instructions in a forum is different than in a room with others. :-) Input numbers used to test were: 5 - 11 and 2 88 - 44044 and 6 188 - 233332 and 7 98 - 0,0 on the RPN contest and RPL is 0,0. (answer is 8,813,200,023,188 and 24) 99899 - 2,217,777,122 and 10 9338 - 0 and 0 on RPN. on RPL 133,697,796,331 and 15. |
|||
09-13-2022, 01:23 PM
Post: #29
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Here's a version that checks only the precision, in a machine-independent way, so the same code will run on a 41, 42 and Free42, making max. use of the available precision.
(eg. 196 will run out of precision on Free42 after 71 iterations.) Code: 00 { 65-Byte Prgm } Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
09-13-2022, 06:21 PM
(This post was last modified: 09-15-2022 12:07 PM by Gerson W. Barbosa.)
Post: #30
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-12-2022 08:03 PM)Gerson W. Barbosa Wrote: (# 559Ah, 221 bytes). We can save a few bytes by eliminating the local variable: Code:
# 1924h, 212.5 P.S.: Or # FD3Hh and 210 bytes, if I place the subprogram between { } instead of « » (I keep on forgetting that). |
|||
09-14-2022, 01:00 AM
(This post was last modified: 10-04-2022 05:44 PM by David Hayden.)
Post: #31
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Here is my winning RPL entry. It can definitely be improved but I ran out of time. It could be restructured so it only reverses the number once. That would mean the list that reverses could be inline.
I'll try to clean it up and post a followup to show what I'm talking about. 185 bytes. #31E0h Code: « |
|||
09-14-2022, 12:47 PM
Post: #32
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-14-2022 01:00 AM)David Hayden Wrote: Here is my winning RPL entry. It can definitely be improved but I ran out of time. It could be restructured so it only reverses the number once. That would mean the list that reverses could be inline. I look forward to your revisions, David! We had a similar approach, so of course I think yours is great. Code: @ Size: 180.0 bytes, CRC: 31DCh I can't recall if the 49 supports IDIV2, so this may be limited to the 49g+/50g. Additionally, this version gains 8 bytes if you happen to transfer it to a calculator set to approximate mode due to the size differences in the numeric constants. @Gene: thanks for posting, and especially for putting up with the requests for clarification. While they may be a pain, it's important to know what is and isn't allowed. This is especially true when a few bytes/nibbles here and there can make all the difference. |
|||
09-14-2022, 02:52 PM
Post: #33
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-14-2022 12:47 PM)DavidM Wrote: I can't recall if the 49 supports IDIV2, so this may be limited to the 49g+/50g. From a User RPL perspective, the 49G supports everything the 49g+/50g supports (of course excluding differences in behavior due to the smaller screen). This is because they use the same ROM -- I believe I have ROM 2.10 on one of my 49G calculators, for example. |
|||
09-14-2022, 06:08 PM
Post: #34
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-11-2022 01:30 AM)Gene Wrote: Problem Description: If you add any positive integer to the integer formed by reversing its digits, then repeat the process with the resulting sum, and keep repeating this loop... will you eventually reach a sum that is palindromic? Has this question been answered? Dave - My mind is going - I can feel it. |
|||
09-14-2022, 06:41 PM
Post: #35
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL | |||
09-15-2022, 01:07 PM
Post: #36
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-14-2022 12:47 PM)DavidM Wrote: Here’s a version of your program with the subroutine on the stack, like David Hayden’s above: Code:
|
|||
09-15-2022, 01:33 PM
Post: #37
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-14-2022 06:41 PM)John Keith Wrote:(09-14-2022 06:08 PM)Jeff O. Wrote: Has this question been answered? Good question, Wikipedia has an entry for Lycrel numbers . While testing my contest entry algorithm I found that 196 did not produce a palindrome before the contest limits were exceed. According to the Wikipedia article this is the first Lycrel number. Try CC41! |
|||
09-15-2022, 02:17 PM
Post: #38
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-15-2022 01:33 PM)Craig Bladow Wrote:(09-14-2022 06:41 PM)John Keith Wrote: No. I was about to post with what I found via the internet-search-engine search that I should have done prior to my initial inquiry, but Craig beat me to it while I was preparing my response. Since I found some info, I'll go ahead and provide: Quote:A Lychrel number is a natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. As Craig noted, 196 is the smallest candidate Lychrel number, having been reversed and added to create a number with a billion digits with no palindrome yet found. Dave - My mind is going - I can feel it. |
|||
09-15-2022, 02:22 PM
Post: #39
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
Has anyone determined if the check for iterations>50 is necessary? In other words, are there any numbers that hit 50 iterations before overflowing 10 or 12 digits?
|
|||
09-15-2022, 03:01 PM
Post: #40
|
|||
|
|||
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-15-2022 02:22 PM)David Hayden Wrote: Has anyone determined if the check for iterations>50 is necessary? In other words, are there any numbers that hit 50 iterations before overflowing 10 or 12 digits? Adding a number to its reverse doubles the number, 'on average' ;-) 2^50 > 1e15, so I guess not. Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)