How to resolve the algorithm ABC problem step by step in the Bracmat programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm ABC problem step by step in the Bracmat 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 Bracmat programming language
Source code in the bracmat programming language
(
( can-make-word
= ABC blocks
. (B O)
+ (X K)
+ (D Q)
+ (C P)
+ (N A)
+ (G T)
+ (R E)
+ (T G)
+ (Q D)
+ (F S)
+ (J W)
+ (H U)
+ (V I)
+ (A N)
+ (O B)
+ (E R)
+ (F S)
+ (L Y)
+ (P C)
+ (Z M)
: ?blocks
& ( ABC
= letter blocks A Z
. !arg:(.?)
| !arg:(@(?:%?letter ?arg).?blocks)
& !blocks
: ?
+ ?*(? !letter ?:?block)
+ (?&ABC$(!arg.!blocks+-1*!block))
)
& out
$ ( !arg
( ABC$(upp$!arg.!blocks)&yes
| no
)
)
)
& can-make-word'A
& can-make-word'BARK
& can-make-word'BOOK
& can-make-word'TREAT
& can-make-word'COMMON
& can-make-word'SQUAD
& can-make-word'CONFUSE
);
You may also check:How to resolve the algorithm Abstract type step by step in the VBA programming language
You may also check:How to resolve the algorithm Collections step by step in the Raven programming language
You may also check:How to resolve the algorithm Sum digits of an integer step by step in the Joy programming language
You may also check:How to resolve the algorithm MAC vendor lookup step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Binary strings step by step in the Red programming language