Jump to content

Deal cards for FreeCell: Difference between revisions

J draft
(→‎Tcl: Added implementation)
(J draft)
Line 76:
return 0;
}</lang>
 
=={{header|J}}==
 
Paraphrase of C:
 
<lang j>deck=: (,/ 'KQJT98765432A' ,"0/ 7 u: '♠♥♦♣')"_
deal=: >@(C.&.>/@|.@;(i. <@<@~."1@,. <: - ] (| rnd)@- i.)@#) @ deck@srnd
show=: (,"2)@:(_8 ]\ ' '&,.)</lang>
 
Example use:
 
<lang j> show deal 1
J♦ 2♦ 9♥ J♣ 5♦ 7♥ 7♣ 5♥
K♦ K♣ 9♠ 5♠ A♦ Q♣ K♥ 3♥
2♠ K♠ 9♦ Q♦ J♠ A♠ A♥ 3♣
4♣ 5♣ T♠ Q♥ 4♥ A♣ 4♦ 7♠
3♠ T♦ 4♠ T♥ 8♥ 2♣ J♥ 7♦
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

Cookies help us deliver our services. By using our services, you agree to our use of cookies.