ABC problem: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
(Added uBasic/4tH version) |
||
Line 9,820: | Line 9,820: | ||
=={{header|uBasic/4tH}}== |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="uBasic/4tH">dim @b(40) ' holds the blocks |
|||
dim @d(20) |
|||
' load blocks from string in lower case |
|||
a := "BOXKDQCPNAGTRETGQDFSJWHUVIANOBERFSLYPCZM" |
|||
For x = 0 To Len (a)-1 : @b(x) = Or(Peek(a, x), Ord(" ")) : Next |
|||
' push words onto stack |
|||
Push Dup("A"), Dup("Bark"), Dup("Book"), Dup("Treat") |
|||
Push Dup("Common"), Dup("Squad"), Dup("Confuse") |
|||
Do While Used() ' as long as words on the stack |
|||
w = Pop() ' get a word |
|||
p = 1 ' assume it's possible |
|||
For x = 0 To 19 : @d(x) = 0 : Next ' zero the @d-array |
|||
For i = 0 To Len(w) - 1 ' test the entire word |
|||
c = Or(Peek(w, i), Ord(" ")) ' get a lower case char |
|||
For x = 0 To 19 ' now test all the blocks |
|||
If @d(x) = 0 Then If (@b(x*2)=c) + (@b(x*2+1)=c) Then @d(x) = 1 : Break |
|||
Next |
|||
If x = 20 Then p = 0 ' we've tried all the blocks - no fit |
|||
Next |
|||
' show the result |
|||
Print Show(w), Show(Iif(p, "True", "False")) |
|||
Loop</syntaxhighlight> |
|||
{{Out}} |
|||
<pre>Confuse True |
|||
Squad True |
|||
Common False |
|||
Treat True |
|||
Book False |
|||
Bark True |
|||
A True |
|||
0 OK, 0:1144</pre> |
|||
=={{header|Ultimate++}}== |
=={{header|Ultimate++}}== |