Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/ABC-problem/BCPL/abc-problem.bcpl
Normal file
37
Task/ABC-problem/BCPL/abc-problem.bcpl
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
get "libhdr"
|
||||
|
||||
let canMakeWord(word) = valof
|
||||
$( let blocks = "BOXKDQCPNAGTRETGQDFSJWHUVIANOBERFSLYPCZM"
|
||||
let avl = vec 40/BYTESPERWORD
|
||||
for i=0 to 39 do avl%i := blocks%(i+1)
|
||||
for i=1 to word%0
|
||||
$( for j=0 to 39
|
||||
$( let ch = word%i
|
||||
// make letter uppercase
|
||||
if 'a' <= ch <= 'z' then ch := ch - 32
|
||||
if ch = avl%j then
|
||||
$( // this block is no longer available
|
||||
avl%j := 0
|
||||
avl%(j neqv 1) := 0
|
||||
// but we did find a block
|
||||
goto next
|
||||
$)
|
||||
$)
|
||||
resultis false // no block found
|
||||
next: loop
|
||||
$)
|
||||
resultis true
|
||||
$)
|
||||
|
||||
let show(word) be
|
||||
writef("%S: %S*N", word, canMakeWord(word) -> "yes", "no")
|
||||
|
||||
let start() be
|
||||
$( show("A")
|
||||
show("BARK")
|
||||
show("book")
|
||||
show("Treat")
|
||||
show("CoMmOn")
|
||||
show("SQUAD")
|
||||
show("CONFUSE")
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue