Mind boggling card trick: Difference between revisions

Added Quackery.
m (→‎{{header|Phix}}: added syntax colouring, made p2js compatible)
(Added Quackery.)
Line 1,581:
Swapping 2
Yeha! The mathematicians assertion is correct.</pre>
 
=={{header|Quackery}}==
 
<lang Quackery>
[ stack ] is discards ( --> s )
[ stack ] is red-card ( --> s )
[ stack ] is black-card ( --> s )
 
[ dup take
rot join
swap put ] is to-pile ( n s --> )
 
[ $ "" discards put
$ "" red-card put
$ "" black-card put
char R 26 of
char B 26 of join shuffle
26 times
[ behead tuck discards to-pile
behead rot char R =
iff red-card else black-card
to-pile ]
drop
discards take witheach
[ emit sp ] cr
red-card take
black-card take
over size over size min random
say "Swapping " dup echo
say " cards." cr
dup dip [ split rot ] split
dip [ swap rot ] join dip join
0 swap witheach
[ char R = if 1+ ]
0 rot witheach
[ char B = if 1+ ]
say "The assertion is "
= iff [ say "true." ]
else [ say "false." ] cr cr ] is task ( --> )
 
5 times task</lang>
 
{{out}}
 
<pre>B B R R R B R R B B B R B B R R R R R B B R B R B R
Swapping 4 cards.
The assertion is true.
 
R R B B R B R B B B B R B R R B R B B B R R B R R R
Swapping 3 cards.
The assertion is true.
 
B R R R B R R R B R R R R B R B R B B R B R B B B R
Swapping 4 cards.
The assertion is true.
 
R B B B B B R B R R R B R B B R R B B R B R R R R B
Swapping 11 cards.
The assertion is true.
 
R B B R B B B B B R R B B B R B R B R B B B R B B B
Swapping 2 cards.
The assertion is true.
</pre>
 
=={{header|R}}==
1,462

edits