Post Reply 
HHC 2015 RPN programming Contest is now open
10-01-2015, 05:45 PM (This post was last modified: 10-01-2015 05:56 PM by Dieter.)
Post: #68
RE: HHC 2015 RPN programming Contest is now open
(09-30-2015 10:13 AM)Egan Ford Wrote:  All stack, 58 bytes (yeah, not even close to my last attempt (42 bytes), but just a different way to solve that none have posted, unless I missed it)

A clever idea. But it can be done in 53 bytes – simply multiply the MODs:

Code:
 01 LBL "RR"                  
 02 5           ; loop over 5 dice
 03 1           ; alternatively use ENTER SIGN
 04 LBL 00
 05 RCL IND Y   ; map to prime number
 06 X^2         ; x^2 - x + 11, x = 0-10 prime
 07 LASTx
 08 -
 09 11
 10 +
 11 *           ; multiply primes
 12 DSE Y
 13 GTO 00
 14 ENTER
 15 ENTER
 16 ENTER
 17 55913       ; check for 1,2,3,4
 18 MOD
 19 X<>Y
 20 157573      ; check for 2,3,4,5
 21 MOD
 22 *
 23 X<>Y
 24 496961      ; check for 3,4,5,6
 25 MOD
 26 *
 27 END

On a standard 41C/CV/CX this runs in about 3 seconds for any input.
Add a final X≠0? SIGN if you prefer an output of 0 or 1.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2015 RPN programming Contest is now open - Dieter - 10-01-2015 05:45 PM



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