[Free42] Minichallenge: ->DATE - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: [Free42] Minichallenge: ->DATE (/thread-15463.html) [Free42] Minichallenge: ->DATE - Werner - 08-13-2020 08:23 AM Flags 31 and 67 control the DATE format in Free42: D.MY F67C, F31S M.DY F67C, F31C Y.MD F67S (F31C) Given YYYY in Z, MM in Y and DD in X, write a routine that will return the date in the current format. Shortes number of lines, then number of bytes. Good luck! Werner While you're at it, write the reverse routine DATE-> as well RE: [Free42] Minichallenge: ->DATE - Didier Lachieze - 08-13-2020 06:54 PM My solution, with YYYY in Z, MM in Y and DD in X, it returns the date in the current format: Code: ```00 { 31-Byte Prgm } 01▸LBL "→DATE" 02 FS? 31 03 X<>Y 04 FC? 67 05 RCL ST Z 06 100 07 FC? 67 08 STO÷ ST Y 09 STO÷ ST Y 10 STO÷ ST Z 11 ÷ 12 + 13 + 14 END``` And the reverse routine: Code: ```00 { 37-Byte Prgm } 01▸LBL "DATE→" 02 IP 03 LASTX 04 FP 05 100 06 × 07 IP 08 LASTX 09 FP 10 100 11 FC? 67 12 STO× ST Y 13 × 14 STO ST T 15 FC? 67 16 R↓ 17 FS? 31 18 X<>Y 19 END``` RE: [Free42] Minichallenge: ->DATE - Werner - 08-13-2020 07:11 PM Close ;-) Actually, the first routine matches mine in line and byte count, but yours can be made 1 byte shorter ;-) I still have a 2 byte edge over the second. Werner RE: [Free42] Minichallenge: ->DATE - Didier Lachieze - 08-13-2020 08:26 PM (08-13-2020 07:11 PM)Werner Wrote:  Close ;-) Actually, the first routine matches mine in line and byte count, but yours can be made 1 byte shorter ;-) You're right, here is the 1 byte shorter version : Code: ```00 { 30-Byte Prgm } 01▸LBL "→DATE" 02 FS? 31 03 X<>Y 04 FC? 67 05 RCL ST Z 06 100 07 FC? 67 08 STO÷ ST Y 09 STO÷ ST Z 10 X↑2 11 ÷ 12 + 13 + 14 END``` RE: [Free42] Minichallenge: ->DATE - Werner - 08-17-2020 06:27 AM here's my entry for DATE→ : Code: ```00 { 35-Byte Prgm } 01 LBL "DATE→" 02 IP 03 LASTX 04 FP 05 100 06 x 07 IP 08 LASTX 09 FP 10 100 11 x 12 FS? 67 13 RTN 14 LASTX 15 x 16 X<> ST Z 17 FC? 31 18 X<>Y 19 END``` Thanks for your participation, Didier! Your routine could again be made 1 byte shorter (X^2 io STOx ST Y), which would make it just 1 byte more than mine, with the same line count. Werner RE: [Free42] Minichallenge: ->DATE - grsbanks - 08-17-2020 12:23 PM (08-17-2020 06:27 AM)Werner Wrote:  Thanks for your participation, Didier! Your routine could again be made 1 byte shorter (X^2 io STOx ST Y) "X^2" and "STOx ST Y" don't do the same thing. With X^2 you end up with Y unchanged and X^2 in X. With STOx ST Y you end up with X*Y in Y and X unchanged. RE: [Free42] Minichallenge: ->DATE - Werner - 08-17-2020 01:13 PM The full code snippet reads Code: ```10 100 11 FC? 67 12 STO× ST Y 13 ×``` and here, STOx ST Y may be replaced by X^2, since LASTX is not used further on. Cheers, Werner