Mind boggling card trick: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: reduced the number of random shuffles.) |
m (→{{header|REXX}}: fixed code to not shuffle the same card.) |
||
Line 702: | Line 702: | ||
isRed: return arg(1) // 2 /*if arg(1) is odd, the card is RED.*/ |
isRed: return arg(1) // 2 /*if arg(1) is odd, the card is RED.*/ |
||
s: if arg(1)==1 then return arg(3); return word( arg(2) 's', 1) /*pluralizer.*/ |
s: if arg(1)==1 then return arg(3); return word( arg(2) 's', 1) /*pluralizer.*/ |
||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
count: Rn=0; Bn=0; do j=1 for words(R); Rn=Rn+ isRed(word(R,j)) ; end |
count: Rn=0; Bn=0; do j=1 for words(R); Rn=Rn+ isRed(word(R,j)) ; end |
||
Line 715: | Line 714: | ||
end /*j*/ |
end /*j*/ |
||
return /*discard pile not used.*/ |
return /*discard pile not used.*/ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
⚫ | |||
parse value @.x @.y with @.y @.x; end /*j*/; return |
|||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
swap: $= min( words(R), words(B) ); Rc=; Bc= /*ensure we can swap $ cards.*/ |
swap: $= min( words(R), words(B) ); Rc=; Bc= /*ensure we can swap $ cards.*/ |