Re: Days between dates challenge for 11c and 34c Message #31 Posted by Mark Edmonds on 12 Aug 2009, 6:57 a.m., in response to message #30 by Katie Wasserman
Here is my version. I haven't looked at anyone elses' code so I don't know how it compares. This was a useful exercise for me and a lot of fun as I don't normally do any programming outside RPL. The 4 line stack and stack-lift problems caught me out a couple of times but here is the result:
64 lines, 1 label, 2 registers.
x SWAP I
Rdown
GSB A
x SWAP I
GSB A
RCL I
-
RTN
LBL A
INT
LASTx
FRAC
EEX
2
*
INT
STO 0
LASTx
FRAC
EEX
4
*
3
6
5
x SWAP y
*
STO+ 0
LASTx
Rup
ENTER
SF 0
1
-
3
1
*
STO+ 0
x SWAP y
3
X>Y
GTO A
Rdown
CF 0
.
4
*
2
.
3
+
INT
STO- 0
LBL A
Rup
F? 0
1
F? 0
-
4
/
INT
RCL 0
+
You will notice that I didn't include an opening label and I took advantage of the implied RTN at the last step. I consider both these omissions legit. It was agreed at the start that an opening label wasn't necessary and my program returns to 000 after each run so no manual re-pointing is necessary. Concerning the implied RTN, HP document this in the manuals so quite happy to use it!
However, this might give me a 2 line advantage so I'll let the adjudicators decide on that one :)
Written on 11C and thanks for the fun challenge!
Mark
PS: Living in a dd.mm.yyyy part of the world, working with mm.dd.yyyy is unbelievably confusing! It's like have to learn left is right!!
Edited: 12 Aug 2009, 7:01 a.m.
|