How to resolve the algorithm ABC problem step by step in the Quackery programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm ABC problem step by step in the Quackery programming language
Table of Contents
Problem Statement
You are given a collection of ABC blocks (maybe like the ones you had when you were a kid).
There are twenty blocks with two letters on each block.
A complete alphabet is guaranteed amongst all sides of the blocks.
The sample collection of blocks:
Write a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.
The rules are simple:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm ABC problem step by step in the Quackery programming language
Source code in the quackery programming language
[ $ "BOXKDQCPNAGTRETGQDFS"
$ "JWHUVIANOBERFSLYPCZM"
join ] constant is blocks ( --> $ )
[ -2 &
tuck pluck drop
swap pluck drop ] is remove2 ( $ n --> $ )
[ iff [ say "True" ]
else [ say "False" ] ] is echotruth ( b --> )
[ true blocks rot
witheach
[ upper over find
2dup swap found
iff remove2
else
[ drop dip not
conclude ] ]
drop echotruth ] is can_make_word ( $ --> )
[ ' [ 0 ] swap
witheach
[ over -1 peek
+ join ]
behead drop ] is accumulate ( [ --> [ )
[ [] swap
witheach
[ swap dip
[ over + ]
swap join ]
nip ] is add ( n [ --> [ )
[ [] unrot
[ 2dup find
2dup swap
found while
1+ split
swap size
dip rot join
unrot again ]
2drop drop
accumulate
-1 swap add ] is findall ( x [ --> [ )
[ iff [ say "True" ]
else [ say "False" ] ] is echotruth ( b --> )
[ $ "BOXKDQCPNAGTRETGQDFS"
$ "JWHUVIANOBERFSLYPCZM"
join ] constant is blocks ( --> $ )
[ -2 &
tuck pluck drop
swap pluck drop ] is remove2 ( $ n --> $ )
forward is (abc)
[ dup [] = if bail
behead upper
dip over swap findall
witheach
[ dip over
remove2
over (abc) ]
2drop ] resolves (abc) ( $ $ --> )
[ blocks swap
2 backup (abc)
bailed dup
if [ dip 2drop ]
echotruth ] is can_make_word ( $ --> )
You may also check:How to resolve the algorithm Vigenère cipher step by step in the Tcl programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Clojure programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm Subleq step by step in the BASIC programming language
You may also check:How to resolve the algorithm Duffinian numbers step by step in the Python programming language