2024 HHC Programming Contest - RPN #1
|
09-24-2024, 06:06 PM
Post: #41
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
And it was my mistake that I did not transcribe Gunters program correctly !
|
|||
09-24-2024, 10:39 PM
Post: #42
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
My own efforts for the HP33 / HP25 are not nearly as inventive as some others, and I couldn't include a label as they are not available.
First attempt Code:
Second attempt (managed to shave off one byte from my original attempt by dividing before adding) Code:
Perhaps I'll get my x11-calc-41c code working before the next HHC Meeting! Mike T. HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S |
|||
09-26-2024, 12:12 PM
Post: #43
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
(09-23-2024 11:06 PM)Paul Dale Wrote: My best entry is: Nicely done!! 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-26-2024, 07:21 PM
Post: #44
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1 | |||
09-26-2024, 07:23 PM
Post: #45
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
Oops. I read it as numeric keys, the rule says numeric digits. My bad.
DGM |
|||
09-26-2024, 07:44 PM
(This post was last modified: 09-26-2024 07:45 PM by ThomasF.)
Post: #46
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
(09-26-2024 07:23 PM)DGM Wrote: Oops. I read it as numeric keys, the rule says numeric digits. My bad. As shown before, it can be solved with only 3 numeric keys (if that was part of the rules): LBL A 777 PI % INT END As a bonus, it only uses 11 bytes in total ... Cheers, Thomas [35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X] |
|||
09-27-2024, 06:11 PM
Post: #47
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
I shared the "PI" solution with Gene during the conference and he said the "use of PI" violated the rule of no numbers other than "7". Therefore my solution was invalidated.
|
|||
09-27-2024, 09:59 PM
(This post was last modified: 09-27-2024 10:08 PM by c3d.)
Post: #48
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
I found this thread quite amusing, and while it's a bit off-topic (although I propose a possible 10-byte solution at the end), I thought that I would compare how much space DB48X uses for the various solutions (since I have been focusing a lot on making it more space-efficient that HP's own RPL implementation).
First, let me start by cheating with a 10 bytes solution: Code:
This is clearly cheating because it takes advantage of the fact that the default precision for DB48X is 24 digits. I think I should also add a rule that the stack at end must ONLY contain 24, so the 777 leftover in that case causes it to fail. But I'll show at end that there are more interesting ways to achieve that result that are probably legit. (09-23-2024 11:04 AM)Gene Wrote: Here are the solutions from the conference: DB48X equivalent is 18 bytes Code:
As a comparison point, it's 40 bytes on the HP50G. Quote:16 bytes: DB48X equivalent is also 16 bytes (here we don't need "DUP" for ENTER since it's only used to separate values): Code:
Quote:LBL A CLΣ Σ+ Σ+ Σ+ ENTER 7 + 7 + 7 + END I think this one is really a 15 bytes answer on the 41, because the rules talk about a clean state, so the initial CLΣ is not necessary. This one also reminded me that Σ+ suppresses stack lift, so the ENTER is not optional. This solution does not exactly work on DB48X, because it relies on implicit zeroes on the stack, which does not work in RPL. An equivalent RPL program therefore diverges too much from the original to be really meaningful, although the following 19-bytes program is relatively close in spirit: Code:
Quote:LBL A 7 ENTER 7 + 7 + STO Y LASTX / + END This one is a bit tricky, because there is no direct equivalent to STO Y. A relatively close approximation are the 17 bytes and 16 bytes programs below: Code:
Quote:14 bytes: The 16-bytes most straight equivalent of this one fails in an interesting way: the ip function complains about a bad argument type because by default atan returns a number with a unit (in my case, 4.004 degrees), and IP does not like that. Code:
Quote:LBL A 7 ENTER 77 LN INT * LASTX - END This one is straightforward, and 13 bytes on DB48X. This is one of the few cases where the DB48X version is actually shorter. Code:
Quote:13 bytes: Also 13 bytes on DB48X: Code:
Quote:LBL A 7 ENTER 7 + 7 ÷ x^2 FACT END Also 13 bytes on DB48X: Code:
Quote:LBL A 77 ENTER 7 P->R e^x INT FACT This one is interesting because DB48X has real complex numbers, both in polar and rectangular form. So the closest approximation would be the following 16-bytes program that takes the real part of a polar number, which uses the same mathematical logic if not the same functions. Code:
Quote:12 bytes: Two issues here. First, COS relies on the default stack value being zero, but that does not work for RPL, where the default stack is empty. Second is atan returning a unit value so that the following "7 -" gives an "Inconsistent units" error. In order to generate the initial zero, I need to add a non-numerical zero producer. DEPTH is a good candidate, with the caveat that the program no longer works correctly if the initial stack is not empty (just like the solution above does not work if the stack contains 1 instead of 0.). In order to address the unit problem, I need to add an UVAL command. This results in a 16-bytes program. Code:
Quote:LBL A 7 Sigma+ 7 Sigma+ 7 Sigma+ RCL 11 END This one does not work for me. As others pointed out, I think you need to replace the final RCL11 with ENTER RCL11 +. As pointed out earlier, the closest DB48X equivalent I can think of is 19 bytes: Code:
Quote:LBL A 777 LOG INT x^2 FACT END This is another scenario where DB48X is slightly shorter, with only 11 bytes for: Code:
Quote:LBL A 77 TAN INT FACT 7 X<>Y END This one is also 12 bytes on DB48X, where I replaced X<>Y with DROP instead of SWAP, because of my requirement that only 24 be left on the stack (otherwise I have a leftover 7). Code:
Quote:LBL A 777 LOG LOG ATAN INT END With the additional UVAL required to get rid of the unit out of ATAN, this leads to a 12-bytes program: Code:
Quote:LBL A 77.7 TAN INT FACT END This one is only 9 bytes on DB48X, making it a winner in this little contest. Code:
Quote:What I love are the wide varieties of the solutions. P->R ? OCT ? :-) Now for the pure DB48X solutions to the problem: Here is a 11-bytes solution that looks somewhat legit to me: Code:
Is ALENG allowed in the contest? If so, what is the size of the following on an HP41? On the HP42, I think that it's 10 bytes, but I don't remember how you get the program size on the HP41, so I'm not sure I am counting right. Code:
On DB48X, I found another 10-bytes solution that I don't like because it relies on internal details and leaves garbage on the stack behind the expected 24: Code:
So I'd say that the current winner so far is 9 bytes: Code:
Can we improve over that? Conclusion: I was mostly interested in seeing how DB48X would compare to the HP41 here, because one of my design objectives for that project was to have an RPL implementation that was, memory-wise, closer to historical HP calculators than to HP's RPL, which old timers like me may remember as a horrible memory hog compared to earlier RPN models. It looks like that so far, that particular goal is reasonably well achieved. :-) DB48X,HP,me |
|||
09-28-2024, 01:54 PM
(This post was last modified: 09-28-2024 01:58 PM by AnnoyedOne.)
Post: #49
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
(09-27-2024 06:11 PM)jjohnson873 Wrote: I shared the "PI" solution with Gene during the conference and he said the "use of PI" violated the rule of no numbers other than "7". Technically correct. pi = 3.1415926536 (approx) so it is a number. However the pi key is not a "digit" so I'd put in the same category as "." (allowable?). That said the "judges decision is final". A1 HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251) |
|||
10-13-2024, 08:51 AM
(This post was last modified: 10-13-2024 09:12 AM by Gilles.)
Post: #50
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
The first thing I thought about in RPL 49-50g is
Code: « 7 7 7 / DUPDUP + + - ! » @CD3, why not : Code: « "77.7" SIZE ! » |
|||
11-09-2024, 08:12 PM
Post: #51
|
|||
|
|||
RE: 2024 HHC Programming Contest - RPN #1
(10-13-2024 08:51 AM)Gilles Wrote: The first thing I thought about in RPL 49-50g is That one is 16 bytes. Quote:@CD3, why not : That is 11 bytes too. I thought I had mentioned it, but it looks like I only mentioned the HP41 equivalent. DB48X,HP,me |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)