Deal cards for FreeCell: Difference between revisions
Content added Content deleted
m (Updated description and link for Fōrmulæ solution) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 68: | Line 68: | ||
* [[Go Fish]] |
* [[Go Fish]] |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>F randomGenerator(=seed, n) |
|||
[Int] r |
|||
-V max_int32 = 7FFF'FFFF |
|||
seed = seed [&] max_int32 |
|||
L r.len < n |
|||
seed = (seed * 214013 + 2531011) [&] max_int32 |
|||
r [+]= seed >> 16 |
|||
R r |
|||
F deal(seed) |
|||
V nc = 52 |
|||
V cards = Array((nc - 1 .< -1).step(-1)) |
|||
V rnd = randomGenerator(seed, nc) |
|||
L(r) rnd |
|||
V j = (nc - 1) - r % (nc - L.index) |
|||
swap(&cards[i], &cards[j]) |
|||
R cards |
|||
F show(cards) |
|||
V l = cards.map(c -> ‘A23456789TJQK’[Int(c / 4)]‘’‘CDHS’[c % 4]) |
|||
L(i) (0 .< cards.len).step(8) |
|||
print((l[i .< i + 8]).join(‘ ’)) |
|||
:start: |
|||
V seed = I :argv.len == 2 {Int(:argv[1])} E 11982 |
|||
print(‘Hand #.’.format(seed)) |
|||
V deck = deal(seed) |
|||
show(deck)</lang> |
|||
{{out}} |
|||
<pre> |
|||
Hand 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|Ada}}== |
=={{header|Ada}}== |