Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/24-game/Potion/24-game.potion
Normal file
40
Task/24-game/Potion/24-game.potion
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
is_num = (s):
|
||||
x = s ord(0)
|
||||
if (x >= "0"ord && x <= "9"ord): true.
|
||||
else: false.
|
||||
.
|
||||
|
||||
nums = (s):
|
||||
res = ()
|
||||
0 to (s length, (b):
|
||||
c = s(b)
|
||||
if (is_num(c)):
|
||||
res push(c).
|
||||
.)
|
||||
res.
|
||||
|
||||
try = 1
|
||||
while (true):
|
||||
r = rand string
|
||||
digits = (r(0),r(1),r(2),r(3))
|
||||
"\nMy next four digits: " print
|
||||
digits join(" ") say
|
||||
digit_s = digits ins_sort string
|
||||
|
||||
("Your expression to create 24 (try ", try, "): ") print
|
||||
entry = read slice(0,-1)
|
||||
expr = entry eval
|
||||
parse = nums(entry)
|
||||
parse_s = parse clone ins_sort string
|
||||
try++
|
||||
if (parse length != 4):
|
||||
("Wrong number of digits:", parse) say.
|
||||
elsif (parse_s != digit_s):
|
||||
("Wrong digits:", parse) say.
|
||||
elsif (expr == 24):
|
||||
"You won!" say
|
||||
entry print, " => 24" say
|
||||
return().
|
||||
else:
|
||||
(entry, " => ", expr string, " != 24") join("") say.
|
||||
.
|
||||
Loading…
Add table
Add a link
Reference in a new issue