Deal cards for FreeCell: Difference between revisions

bugfix -- J: include rng! (and code cleanup)
m (J: deck can be a noun, now)
(bugfix -- J: include rng! (and code cleanup))
Line 82:
 
<lang j>deck=: ,/ 'KQJT98765432A' ,"0/ 7 u: '♠♥♦♣'
 
srnd=: 3 :'SEED=:{.y,11982'
srnd ''
seed=: do bind 'SEED'
rnd=: (2^16) <.@%~ (2^31) srnd@| 2531011 + 214013 * seed
 
pairs=: i. <@<@~."1@,. <: - ] (| rnd)@- i.
swaps=: [: > C.&.>/@|.@;
deal=: deck (swaps pairs@#)@[ srndbind deck
 
show=: (,"2)@:(_8 ]\ ' '&,.)</lang>
 
Example use:
 
<lang j> show deal srnd 1
J♦ 2♦ 9♥ J♣ 5♦ 7♥ 7♣ 5♥
K♦ K♣ 9♠ 5♠ A♦ Q♣ K♥ 3♥
Line 97 ⟶ 104:
6♦ 8♠ 8♦ Q♠ 6♣ 3♦ 8♣ T♣
6♠ 9♣ 2♥ 6♥</lang>
 
Note that this version ignores the special case handling of game 11982, which is not currently documented in the task.
 
=={{header|Tcl}}==
6,962

edits