Deal cards for FreeCell: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by 2 users not shown)
Line 1,156:
4♠ T♠ 2♥ 5♦ J♣ 6♣ J♥ Q♥
J♦ K♠ K♣ 4♥</pre>
=={{header|EasyLang}}==
{{trans|Phix}}
<syntaxhighlight>
global seed .
func xrnd .
seed = (seed * 214013 + 2531011) mod 0x80000000
return seed div 0x10000
.
len cards[] 52
proc deal game_num . .
print "hand " & game_num
seed = game_num
for i = 1 to 52
cards[i] = 52 - i
.
for i = 1 to 51
j = 52 - xrnd mod (53 - i)
swap cards[i] cards[j]
.
.
suits$[] = strchars "CDHS"
ranks$[] = strchars "A23456789TJQK"
#
proc show . .
for idx = 1 to 52
rank = cards[idx] div 4 + 1
suit = cards[idx] mod 4 + 1
write ranks$[rank] & suits$[suit] & " "
if idx mod1 13 = 13
print ""
.
.
print ""
.
deal 1 ; show
deal 617 ; show
</syntaxhighlight>
 
=={{header|Elixir}}==
{{trans|Ruby}}
Line 2,975 ⟶ 3,013:
KC 8D 2S 3S</pre>
 
=={{header|Quackery}}==
 
<code>MCR-seed</code> and <code>MCR-rand</code> are defined at [[Linear congruential generator#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ [ [] 52 times
[ i^ join ] ]
constant ] is newpack ( --> n )
 
[ 2dup peek
dip [ over -1 peek ]
swap 2swap poke
-1 poke ] is to-end ( [ n --> [ )
 
[ [] swap
52 times
[ MCR-rand
over size mod
to-end
-1 split
swap dip join ]
drop ] is mixem ( [ --> [ )
 
[ 4 /mod
$ "A23456789TJQK"
rot peek emit
$ "CDHS"
swap peek emit ] is echocard ( n --> )
 
[ witheach
[ echocard
i^ 8 mod 7 =
iff cr else sp ] ] is echopack ( [ --> )
 
[ MCR-seed replace
newpack
mixem
echopack ] is deal ( n --> )
 
' [ 1 617 11982 ]
witheach
[ say "Deal #"
dup echo cr
deal cr cr ]</syntaxhighlight>
 
{{out}}
 
<pre>Deal #1
JD 2D 9H JC 5D 7H 7C 5H
KD KC 9S 5S AD QC KH 3H
2S KS 9D QD JS AS AH 3C
4C 5C TS QH 4H AC 4D 7S
3S TD 4S TH 8H 2C JH 7D
6D 8S 8D QS 6C 3D 8C TC
6S 9C 2H 6H
 
Deal #617
7D AD 5C 3S 5S 8C 2D AH
TD 7S QD AC 6D 8H AS KH
TH QC 3H 9D 6S 8D 3D TC
KD 5H 9S 3C 8S 7H 4D JS
4C QS 9C 9H 7C 6H 2C 2S
4S TS 2H 5D JC 6C JH QH
JD KS KC 4H
 
Deal #11982
AH AS 4H AC 2D 6S TS JS
3D 3H QS QC 8S 7H AD KS
KD 6H 5S 4D 9H JH 9S 3C
JC 5D 5C 8C 9D TD KH 7C
6C 2C TH QH 6D TC 4S 7S
JD 7D 8H 9C 2H QD 4C 5H
KC 8D 2S 3S
</pre>
 
=={{header|R}}==
Line 3,671 ⟶ 3,782:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">class Lcg {
construct new(a, c, m, d, s) {
_a = a
9,488

edits