HHC 2015 RPN programming Contest is now open
|
09-27-2015, 11:54 PM
(This post was last modified: 09-28-2015 01:21 PM by Bill (Smithville NJ).)
Post: #21
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
I took a pass at it. 40 steps and 75 bytes on an HP-42S using only HP-41C instructions (I hope).
Code:
There should be some opportunity to make it smaller, but I'm just happy that I was able to come up with a solution to it. I forgot how rusty I was with programming a calculator (I don't do it much any more). It gave me an opportunity to re-familiarize myself with the HP-41C manual. Lots of fun. Bill Smithville Edit: Minor Change of Program LBL to "RR". Jud now actually read the complete Rules. |
|||
09-28-2015, 12:21 AM
Post: #22
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-27-2015 09:02 PM)Egan Ford Wrote: I think my solution is the same as yours, however a bit longer and one less register. Gerson, Egan, Very nice solutions! Here is what I finished last night. I have not edited it for optimization but nothing is obvious to me without rethinking how it's done: http://www.enterhp.com/images/HHC2015_AllenT.zip (Zip file includes python test code, and 2 routines to check every possible YATZEE solution, along with a RAW file for Free42.) I chose base 2 so I can do the bitmasks (16) and (15) in 3 bytes. Code:
Here is my 41-byte 42s solution: Code:
17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-28-2015, 12:53 AM
(This post was last modified: 09-28-2015 01:33 AM by Egan Ford.)
Post: #23
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
HP 41C
40 Bytes 26 Lines Code:
|
|||
09-28-2015, 01:29 AM
Post: #24
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
Egan,
Very beautiful solutions- I need to study the 40 byte soution.. at first glance, it is a total mystery how it beautifully works! I have not checked the early termination, but I see you call STOP before the end of the code in a few of your programs? Do your solutions satisfy rule 7 form the contest description? (e.g. if new data is entered and R/S is pressed it will continue?). I'm not that familiar with the HP 41-- somewhere I read on the 42S if you use a STOP command in a program, execution will resume from that point if R/S is pressed, not return to the beginning of the label? Quote: "[Contest Rule] 7)...successive runs must work with pressing R/S." 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-28-2015, 01:31 AM
Post: #25
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open | |||
09-28-2015, 01:35 AM
Post: #26
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 01:29 AM)Allen Wrote: Do your solutions satisfy rule 7 form the contest description? (e.g. if new data is entered and R/S is pressed it will continue?). I'm not that familiar with the HP 41-- somewhere I read on the 42S if you use a STOP command in a program, execution will resume from that point if R/S is pressed, not return to the beginning of the label?Hmmm... Probably not. Back to work. |
|||
09-28-2015, 01:40 AM
Post: #27
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 12:21 AM)Allen Wrote: Here is what I finished last night. I have not edited it for optimization but nothing is obvious to me without rethinking how it's done: http://www.enterhp.com/images/HHC2015_AllenT.zip Allen, Nice documentation provided by you and others, unlike my uncommented code. I started only yesterday, late at night. I wasn't thinking of trying this one, so I am glad I came up with a working solution. I hope the lack of comments might be compensated by a QBASIC program which checks every permutation and gives a list of the only 16 permutations that passes three consecutive tests (I had to make sure these three tests would suffice). It is interesting to see the various approaches presented in this thread for the same problem. Gerson. Code:
|
|||
09-28-2015, 01:42 AM
Post: #28
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
Updated version to comply with rule 7.
Bytes: 42 Lines: 27 Code:
|
|||
09-28-2015, 01:52 AM
(This post was last modified: 09-28-2015 02:02 AM by David Hayden.)
Post: #29
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
[ Edit: OOPS! Nevermind. I completely discounted a die that rolls 6. In fact the whole thing is wrong]
18 steps and 35 bytes, if I'm counting the bytes right. No registers, no sorting. Code:
|
|||
09-28-2015, 02:12 AM
Post: #30
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 01:52 AM)David Hayden Wrote: [ Edit: OOPS! Nevermind. I completely discounted a die that rolls 6. In fact the whole thing is wrong] I started with a similar attempt, I think you're missing CF 1 - CF 6 to initialize at start? Too bad we could not use the CX, e.g. X<>F would have been very handy. My first thought on solving this was to or the bits, then and with 3 different masks and check for 15, 30, or 60. That's mostly what my 64 byte attempt was but with base-10. |
|||
09-28-2015, 02:21 AM
Post: #31
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 01:52 AM)David Hayden Wrote: Dave, Is this loop assuming the flags are initialized to clear? What happens if they aren't? Or am I missing something here. Thanks, Bill Smithville, NJ |
|||
09-28-2015, 02:22 AM
Post: #32
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 02:12 AM)Egan Ford Wrote: Too bad we could not use the CX, e.g. X<>F would have been very handy. My first thought on solving this was to or the bits, then and with 3 different masks and check for 15, 30, or 60. I agree! Even with an AND function, one can check for one of the following numbers (binary) [63,62,61,60,47,31,30,15] with out much trouble. x AND x/2 AND x/4 AND x/8. If the result is >0 then x was one of those numbers. 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-28-2015, 02:27 AM
(This post was last modified: 09-28-2015 12:41 PM by Bill (Smithville NJ).)
Post: #33
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 02:12 AM)Egan Ford Wrote: My first thought on solving this was to or the bits, then and with 3 different masks and check for 15, 30, or 60. Egan, That is similar to what I did. It would be interesting to program this on the HP-16 or even the HP-42S with bit logic. I ended up with a compare with 1111, 11110 and 111100, and used the flags 1-6 to simulate binary. Not the shortest program, but still interesting to program. Fascinating to see the various methods. Bill Smithville, NJ |
|||
09-28-2015, 02:32 AM
Post: #34
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
As a side note, I considered using SCI/FIX/ENG commands because you can set up to 6 flags at the same time and read them out independently. One of the rules made this impractical.
17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-28-2015, 07:25 AM
Post: #35
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 12:53 AM)Egan Ford Wrote: [code] Nested loops and stats - good trick I need to understand the lines above, btw this is similar to my solution - but far compacted and well engineered. I need to learn how indirect addressing with ISG/DSE works on 41xx (start/end values for a loop how set on your program) or/and maybe the stat registers used by your loops also...?! I will read the manual first. Congratulations! Csaba |
|||
09-28-2015, 11:00 AM
Post: #36
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
Egan, Congratulations. Yours is smaller than the other programs!
Thank you for such a compact demonstration of the different registers! 17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b |
|||
09-28-2015, 01:27 PM
Post: #37
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
Question to Gene and others:
I finally read the complete set of Rules. I know, I should have read them BEFORE I did a program, but who reads rules, manuals, etc. Rule No. 13 says to "Assume default machine settings" and "program must stop with the default settings in place". What are considered the "Default machine settings"? Thanks, Bill Smithville, NJ |
|||
09-28-2015, 02:44 PM
Post: #38
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
44 bytes including label and END, pure stack solution. I didn't look at any of the others (so far), honest ;-)
Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
09-28-2015, 03:30 PM
(This post was last modified: 10-02-2015 12:08 PM by Gerson W. Barbosa.)
Post: #39
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 01:27 PM)Bill (Smithville NJ) Wrote: I finally read the complete set of Rules. I know, I should have read them BEFORE I did a program, but who reads rules, manuals, etc. I ought to, but sometimes I don't pay much attention to rules and regulations. Just a glance at the rules and as a result I skipped rule #7 (well, that shouldn't be easy to fix, but I won't). Also, until minutes before I posted my program was labeled simply "S". (09-28-2015 01:27 PM)Bill (Smithville NJ) Wrote: Rule No. 13 says to "Assume default machine settings" and "program must stop with the default settings in place". Aren't these the ones when the calculator is first powered up, or after a reset? "Assume default machine settings" followed by "any default setting that might have been changed during program execution should be restored at program completion", or something like that. This would prevent an obedient programmer from including a line "FIX 4" (or equilavent flag settings), for instance, even if no display mode changing instruction had been used. Gerson. Edited to remove somewhat irrelevant part. |
|||
09-28-2015, 04:22 PM
Post: #40
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 03:30 PM)Gerson W. Barbosa Wrote: Aren't these the ones when the calculator is first powered up, or after a reset? "Assume default machine settings" followed by "any default setting that might have been changed during program execution should be restored at program completion", or something like that. This would prevent an obedient programmer from including a line "FIX 4" (or equilavent flag settings), for instance, even if no display mode changing instruction had been used. Then that would mean that there's no need to clear the flags at the start of the program, but would need to clear them when finished to get them back to Default Machine settings. I'm not sure I'm a fan of this rule. I have would preferred it that there's no assumption made on the calculator initial settings. Other than registers 1-5 containing the test data. Thanks, Bill WD9EQD |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 68 Guest(s)