How to resolve the algorithm ABC problem step by step in the BaCon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm ABC problem step by step in the BaCon 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 BaCon programming language
Source code in the bacon programming language
CONST info$ = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM"
DATA "A", "BARK", "BOOK", "TREAT", "Common", "Squad", "Confuse"
WHILE TRUE
READ word$
IF NOT(LEN(word$)) THEN BREAK
block$ = info$
count = AMOUNT(block$)
FOR y = 1 TO LEN(word$)
FOR x = 1 TO AMOUNT(block$)
IF TALLY(TOKEN$(block$, x), MID$(UCASE$(word$), y, 1)) THEN
block$ = DEL$(block$, x)
BREAK
END IF
NEXT
NEXT
PRINT word$, IIF$(LEN(word$) = count-AMOUNT(block$), "True", "False") FORMAT "%-10s: %s\n"
WEND
You may also check:How to resolve the algorithm Binary digits step by step in the Racket programming language
You may also check:How to resolve the algorithm UTF-8 encode and decode step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Temperature conversion step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Monte Carlo methods step by step in the R programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the 6502 Assembly programming language