Post Reply 
HHC 2015 RPN programming Contest is now open
10-15-2015, 08:05 PM
Post: #101
RE: HHC 2015 RPN programming Contest is now open
(10-15-2015 11:51 AM)Jeff O. Wrote:  Thanks for the information, and for not telling me to "RTFI" (Read the Fine Internet). :-)

I see the internet not as a given but as something we weave with our posts, questions and answers. Of course, we can google everything. But from somewhere, the connections also come.
If you see someone with a map, who acts lost, you can still show him the way, even if he holds all the information required in his hands.
It was far from obvious what you have to search for to solve your problem. The Wikipedia article describes the general solution better than I could ever explain. So thanks for making me read it.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
10-16-2015, 10:40 AM
Post: #102
RE: HHC 2015 RPN programming Contest is now open
Thanks for the nice words, Jeff!
Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
10-20-2015, 04:35 PM (This post was last modified: 01-26-2016 09:08 PM by Guenter Schink.)
Post: #103
RE: HHC 2015 RPN programming Contest is now open
(09-30-2015 12:23 PM)Gene Wrote:  
(09-29-2015 09:25 AM)Werner Wrote:  Managed to squeeze off a byte:
42 bytes
.....
Cheers, Werner

Gene: Werner, of all the code posted so far, yours is the one I like the best. It is short and disturbs other aspects of the machine the least. If you don't mind, I'd like to incorporate some modification of your approach into my Yahtzee game for the funstuff rom?

Nearly *every* posting here is shorter than my efforts, which is why I posed this as the programming contest problem. :-)

I will post my version and Gunter's version from the conference later today if at all possible.

thanks all...

After the conference Torben and I continued our trip through southeast USA via Memphis, Columbia and Charleston back to Dulles Airport. And after that I spent a couple of days at Vienna, Austria. Therefore I'm somewhat late at this subject.
But I guess that my code -winning the contest at the conference- may be still of interest. [edited a typo]

47 bytes
Code:

01 LBL 'RR
00 2XEQ 'SORT
03 RCL 02      If die two is 2
04 RCL 04      and die 4 is 5
05 *
06 10
07 X=Y?         then there is no straight
08 RTN
09 2.005
10 STO 06      init loop counter
11 FRC
12 STO 07      init match counter
13 RCL 01      first die
14LBL 00      start loop
15 1
16 +               add 1 to die
17 RCL IND 06    get next die
18 X=Y?          if true we have a match
19 ISG 07       and increase the match count
20 ISG 06       next die
21 GTO 00
22 3
23 RCL 07      were there 3 or more matches?
24 X>Y?        if true we have a straight and ...
25 CLX         return 0, otherwise leave as it is
26 END

Eventually I looked for squeezing some bytes while retaining the same logic. Here is the result. Using the stack only and DSE instead of ISG, no registers, no flags.

42 bytes
Code:

01 LBL 'RR
02 XEQ 'SORT
03 RCL 02
04 RCL 04
05 *
06 10
07 X=Y?
08 RTN
09 4
10 RCL 05
11 ENTER ^
12 LBL 00
13 SIGN
14 -
15 RCL IND Y
16 X=Y?
17 DSE T
18 X<>Y
19 DSE Z
20 GTO 00
21 R^
22 8
23 x>Y?
24 CLX
25 END

But I must admit that I rate Werner's code as more elegant and perhaps easier to understand. My luck he wasn't at the conference Smile

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)