HHC 2015 RPN programming Contest is now open
|
10-05-2015, 06:33 PM
(This post was last modified: 10-07-2015 04:48 PM by Jeff O..)
Post: #94
|
|||
|
|||
RE: HHC 2015 RPN programming Contest is now open
As is my usual practice, I worked on the challenge for a while before checking the discussion here.
I initially resisted methods that required the sort routine. I worked through a few methods, best I could do was 32 steps/56 bytes using flags. I kept having nagging misgivings about using flags, when to clear them, etc. So I worked on a scheme where I stored ones in a sequence of registers, and “optimized” that down to 42 steps/66 bytes. With this concept, I kept having nagging misgivings about using registers and when to clear them. So I finally PMed Gene and asked about the propriety of using flags and/or registers. He said the rules did not prevent it, but that “in reality the routine is in the middle of a program that uses the first 15 user flags and has most registers spoken for.” So I decided to abandon my reticence to using the sort routine and see if that would help me develop shorter/better programs. After a few iterations, I arrived at 25 step/45 byte version that re-uses register 5, but no other registers or flags, and a 26 step/46 byte version that uses no flags or registers and preserves all of the die values, in case they are needed later in the Yahtzee program. These two programs are presented below for those who might be interested. I thought about the problem for a couple of days, trying to come up with alternate approaches that might lead to shorter programs, but had no flashes of inspiration, so I finally read this thread. As I suspected, there were some approaches that made sense and I might have arrived at independently had I kept devoting time to the problem, and others I would never have thought of in million years (e.g., using prime numbers.) Thanks Gene for another fun project. Code:
- edited for the sake of brevity, improve program comments, and to correct typos Dave - My mind is going - I can feel it. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 7 Guest(s)