1) No posting of any solutions to this forum until after 4pm central time SUNDAY 9/27.
2) Size of routine is all that matters.
3) No synthetic functions, etc. ONLY vanilla CAT 3 HP 41c functions allowed.
Problem and rules found here:
HP 2015 Programming Contest
Questions? Ask me, but don't ask questions that might give things away. Enjoy.
Goal is to have fun.
(09-26-2015 12:59 PM)Gene Wrote: [ -> ]Questions?
A.) 1-2-3-4-5 and 2-3-4-5-6 is not a Small Straight.
B.) 15C programs are OK?!?
Csaba
(09-26-2015 06:15 PM)Csaba Tizedes Wrote: [ -> ] (09-26-2015 12:59 PM)Gene Wrote: [ -> ]Questions?
A.) 1-2-3-4-5 and 2-3-4-5-6 is not a Small Straight.
B.) 15C programs are OK?!?
Csaba
While 1-2-3-4-5 and 2-3-4-5-6 are a Large Straight, they are also considered a Small Straight. There are occasions in Yahtzee where you might want to score a Large Straight as a Small Straight. See the following rules:
Yahtzee Rules
Bill
Smithville, NJ
Bill is correct.
12345 contains two small straights - 1234 and 2345. All you need is one, so 12345 and 23456 are valid for a "small straight."
15C programs are fine, but be careful not to use a 15c instruction that is not a vanilla HP 41C instruction. No SOLVE lines in the program please. :-)
(09-26-2015 06:53 PM)Bill (Smithville NJ) Wrote: [ -> ]might want to score a Large Straight as a Small Straight
OK, It's clear now - thanks!
Csaba
How about a special mention for the highest byte count program that works ??
(the rest of the country seems to place a very high value on bloatware)
Oops. This line on the programming contest file:
"(C) 12356, 11111, 41623, 22344, etc., and then R/S should return something (anything) other than 0."
Is incorrect. My fault.
41623 actually CONTAINS a small straight. If those values are fed into the routine, it should return a 0 because that is a small straight. The instructions/test case for that input is not correct.
Sorry about that. Thanks Jackie!
HP-41C 2121B58157. Main program has 44 steps including LBL and END, including one CALL to the SORT routine, but surely can be made a bit shorter. Also, some unelegant parts have to be rewritten, but I don't think I'll do that on time. About 70 bytes (not taking into account three extra registers) on the HP-42S (used only for byte-counting purpose), which compares to what was already available since the beginning. Running time about 7.5 seconds, including sorting time. I've forgotten to remove the Advantage Module, but I don't think I have used any forbidden routine or instruction.
Thanks for another interesting programming contest. I hope you all are having fun at HHC 2015!
Gerson.
(09-27-2015 11:50 AM)Gerson W. Barbosa Wrote: [ -> ]Thanks for another interesting programming contest. I hope you all are having fun at HHC 2015!
I agree! Thank you, Gene for a fun programming contest. I will not be home at 4pm central, but will post my solution later tonight.
Code:
Steps: 41 (including LBL RR and END)
Bytes: 66
Sorts: 0
Registers: 8 (including 1-5 stored data)
User Flags: 1
Running Time: Varies according to input
I wrote my original solution on the 42S but it used some functions that were not vanilla 41c instructions.
Code:
Steps: 25 (including LBL RR and END)
Bytes: 41
Sorts: 0
Registers: 6 (including 1-5 stored data)
User Flags: 0
Running Time: Constant time, about 56 program steps.
I can include the 42s version tonight if anyone is interested.
(09-26-2015 06:57 PM)Gene Wrote: [ -> ]Bill is correct.
12345 contains two small straights - 1234 and 2345. All you need is one, so 12345 and 23456 are valid for a "small straight."
15C programs are fine, but be careful not to use a 15c instruction that is not a vanilla HP 41C instruction. No SOLVE lines in the program please. :-)
HP15C:
53 steps with one GSB for SORT, including LBL/RTN of main program
R1~R5 + R0, R6 and I
approx. 14-15secs if we have Small straight
pdf doc will be posted at 10PM CET
Thanks for this fun!
Csaba
In case it is useful for testing, here is a simple input routine:
Code:
01>LBL 'INP
02 5
03 STO 00
04 X<>Y
05>LBL 00
06 10
07 /
08 LASTX
09 RCL Y
10 FRC
11 *
12 STO IND 00
13 RDN
14 INT
15 DSE 00
16 GTO 00
17 END
Enter the five numbers as a single five-digit number.
Congratulations to Allen, Csaba and everyone who have been working on this, especially to the people at HHC-2015. I guess it is a bit more difficult there, given the many activities they're participating in. I'm looking foward to your solutions!
Gerson.
(09-27-2015 06:53 PM)Gerson W. Barbosa Wrote: [ -> ]I'm looking foward to your solutions!
Just one and half hour - I wrote a little mistake, because in Hungary 10 PM is only 3 PM in Central Time Zone, so I must to wait one additional hour now...
Csaba
(09-27-2015 12:55 PM)Allen Wrote: [ -> ]
Code:
Steps: 41 (including LBL RR and END)
Bytes: 66
Sorts: 0
Registers: 8 (including 1-5 stored data)
User Flags: 1
Running Time: Varies according to input
I think my solution is the same as yours, however a bit longer and one less register.
Code:
1 LBL RR
2 CF 0
3 5
4 STO 00
5 CLx
6 LBL 01
7 ENTER
8 ENTER
9 RCL IND 00
10 10^x
11 STO 06
12 /
13 INT
14 10
15 MOD
16 x>0?
17 SF 0
18 Rv
19 FC?C 0
20 GTO 02
21 RCL 06
22 +
23 LBL 02
24 DSE 00
25 GTO 01
26 STO 06
27 3
28 STO 00
29 LBL 03
30 RCL 06
31 10
32 /
33 INT
34 STO 06
35 10000
36 MOD
37 1111
38 X<=Y?
39 GTO 04
40 DSE 00
41 GTO 03
42 STOP
43 LBL 04
44 CLx
45 END
First pass, need to optimize for size.
Recall arithmetic wasn't missed this time, but the lack of some comparison tests on the HP-41 is always a problem, at least for me. Not so much improvement when compared to the first version this morning:
Code:
.........................
01>LBL 'RR
02 XEQ 'SORT
03 CLX
04 STO 06
05 STO 07
06 4
07 STO 00
08 SIGN
09>LBL 00
10 RCL IND 00
11 CHS
12 RCL 00
13 RCL Z
14 +
15 RCL IND X
16 X<>Y
17 RDN
18 +
19 X=Y?
20 ST+ 06
21 X<>Y
22 X>Y?
23 ST+ 07
24 DSE 00
25 GTO 00
26 RCL 07
27 RCL 06
28 X<=Y?
29 GTO 01
30 3
31 X>Y?
32 GTO 01
33 RCL 04
34 RCL 02
35 -
36 X<>Y
37 X<=Y?
38 GTO 01
39 FRC
40 RTN
41>LBL 01
42 SIGN
43 END
The program returns 0 for small straights and 1 othewise.
.........................
01>LBL 'SORT ; Sort routine by Jean-Marc Baillard
02 1.005
03 SIGN
04>LBL 01
05 LASTX
06 LASTX
07 RCL IND L
08>LBL 02
09 RCL IND Y
10 X>Y?
11 GTO 03
12 X<>Y
13 LASTX
14 +
15>LBL 03
16 RDN
17 ISG Y
18 GTO 02
19 X<> IND L
20 STO IND Z
21 ISG L
22 GTO 01
23 END
.........................
Gerson.
Edited to fix a typo
Improved version:
Code:
8 REG
0 FLAG
40 LINES
64 BYTES
1 LBL RR
2 5
3 STO 00
4 CLx
5 STO 07
6 LBL 01
7 RCL 07
8 RCL IND 00
9 10^x
10 STO 06
11 /
12 INT
13 10
14 MOD
15 x>0?
16 GTO 02
17 RCL 06
18 ST+ 07
19 LBL 02
20 DSE 00
21 GTO 01
22 3
23 STO 00
24 LBL 03
25 RCL 07
26 10
27 /
28 INT
29 STO 07
30 10000
31 MOD
32 1111
33 X<=Y?
34 GTO 04
35 DSE 00
36 GTO 03
37 STOP
38 LBL 04
39 CLx
40 END
The winning Nashville solution was 47 bytes. Ouch. Much smaller than my previous effort.
I will post the code soon. Gunter Schink is the winner of the local contest.
(09-27-2015 09:47 PM)Gene Wrote: [ -> ]The winning Nashville solution was 47 bytes. Ouch. Much smaller than my previous effort.
I should probably know this, but I do not recall. How do you measure bytes? Thanks.
(09-27-2015 10:00 PM)Egan Ford Wrote: [ -> ] (09-27-2015 09:47 PM)Gene Wrote: [ -> ]The winning Nashville solution was 47 bytes. Ouch. Much smaller than my previous effort.
I should probably know this, but I do not recall. How do you measure bytes? Thanks.
There are tables, but an easier way is checking on the HP-42S or Free42, assuming the byte-counts are the same (not so sure, though).
(09-27-2015 10:00 PM)Egan Ford Wrote: [ -> ]I should probably know this, but I do not recall. How do you measure bytes? Thanks.
There might be other tools, but the easiest way is using an HP41CX: Here CATÂ 1 shows the byte count of each program along with its END.
Or simply plug in an X-Functions Module and save the program to Extended Memory (SAVEP). Then RCLPT returns the number of bytes. ;-)
Dieter