How to resolve the algorithm ABC problem step by step in the Insitux programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm ABC problem step by step in the Insitux 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 Insitux programming language
Source code in the insitux programming language
(function in-block? c
(when (let block-idx (find-idx (substr? (upper-case c)) rem-blocks))
(var! rem-blocks drop block-idx)))
(function can-make-word word
(var rem-blocks ["BO" "XK" "DQ" "CP" "NA" "GT" "RE" "TG" "QD" "FS" "JW" "HU" "VI" "AN" "OB" "ER" "FS" "LY" "PC" "ZM"])
(.. and (map in-block? word)))
(-> ["A" "bark" "Book" "TREAT" "Common" "squaD" "CoNFuSe"] ; Notice case insensitivity
(map #(str % " => " (can-make-word %)))
(join ", "))
You may also check:How to resolve the algorithm Loops/Downward for step by step in the C# programming language
You may also check:How to resolve the algorithm XML/Input step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Random number generator (device) step by step in the Batch File programming language
You may also check:How to resolve the algorithm 15 puzzle solver step by step in the C programming language
You may also check:How to resolve the algorithm Empty directory step by step in the Delphi programming language