Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l
Normal file
19
Task/Bulls-and-cows-Player/PicoLisp/bulls-and-cows-player.l
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(load "@lib/simul.l")
|
||||
|
||||
(de bullsAndCows ()
|
||||
(let Choices (shuffle (mapcan permute (subsets 4 (range 1 9))))
|
||||
(use (Guess Bulls Cows)
|
||||
(loop
|
||||
(prinl "Guessing " (setq Guess (pop 'Choices)))
|
||||
(prin "How many bulls and cows? ")
|
||||
(setq Bulls (read) Cows (read))
|
||||
(setq Choices
|
||||
(filter
|
||||
'((C)
|
||||
(let B (cnt = Guess C)
|
||||
(and
|
||||
(= Bulls B)
|
||||
(= Cows (- (length (sect Guess C)) B)) ) ) )
|
||||
Choices ) )
|
||||
(NIL Choices "No matching solution")
|
||||
(NIL (cdr Choices) (pack "The answer is " (car Choices))) ) ) ) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue