Anonymous user
Deal cards for FreeCell: Difference between revisions
Updated to work with Nim 1.4.
MaiconSoft (talk | contribs) (Added Delphi example) |
(Updated to work with Nim 1.4.) |
||
Line 2,262:
{{trans|Python}}
<lang nim>import sequtils, strutils, os
proc randomGenerator(seed: int): iterator: int =
var
return iterator: int =
while true:
yield
proc deal(seed: int): seq[int] =
const nc = 52
result = toSeq countdown(nc - 1, 0)
var rnd = randomGenerator seed
for i in 0 ..
let r = rnd()
let j = (nc - 1) - r mod (nc - i)
swap result[i], result[j]
proc show(cards: seq[int]) =
var l = newSeq[string]()
for c in cards:
Line 2,285:
for i in countup(0, cards.high, 8):
echo " ", l[i..min(i+7, l.high)].join(" ")
let seed = if paramCount() == 1: paramStr(1).parseInt else: 11982
echo "Hand ", seed
|