Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/ABC-problem/Forth/abc-problem.fth
Normal file
30
Task/ABC-problem/Forth/abc-problem.fth
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
: blockslist s" BOXKDQCPNAGTRETGQDFSJWHUVIANOBERFSLYPCZM" ;
|
||||
variable blocks
|
||||
: allotblocks ( -- ) here blockslist dup allot here over - swap move blocks ! ;
|
||||
: freeblocks blockslist nip negate allot ;
|
||||
: toupper 223 and ;
|
||||
|
||||
: clearblock ( addr-block -- )
|
||||
dup '_' swap c!
|
||||
dup blocks @ - 1 and if 1- else 1+ then
|
||||
'_' swap c!
|
||||
;
|
||||
|
||||
: pickblock ( addr-input -- addr-input+1 f )
|
||||
dup 1+ swap c@ toupper ( -- addr-input+1 c )
|
||||
blockslist nip 0 do
|
||||
blocks @ i + dup c@ 2 pick ( -- addr-input+1 c addri ci c )
|
||||
= if clearblock drop true unloop exit else drop then
|
||||
loop drop false
|
||||
;
|
||||
|
||||
: abc ( addr-input u -- f )
|
||||
allotblocks
|
||||
0 do
|
||||
pickblock
|
||||
invert if drop false unloop exit cr then
|
||||
loop drop true
|
||||
freeblocks
|
||||
;
|
||||
|
||||
: .abc abc if ." True" else ." False" then ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue