How to resolve the algorithm Comma quibbling step by step in the Run BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Comma quibbling step by step in the Run BASIC programming language
Table of Contents
Problem Statement
Comma quibbling is a task originally set by Eric Lippert in his blog.
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
Test your function with the following series of inputs showing your output here on this page:
Note: Assume words are non-empty strings of uppercase characters for this task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Comma quibbling step by step in the Run BASIC programming language
Source code in the run programming language
wrds$ = "[]
[""ABC""]
[""ABC"", ""DEF""]
[""ABC"", ""DEF"", ""G"", ""H""]
"
while word$(wrds$,j+1,chr$(13)) <> ""
a$ = word$(wrds$,j+1,chr$(13))
print a$;" ==> ";
a$ = "{"+mid$(a$,2,len(a$)-2)+"}"
j = j + 1
for i = len(a$) to 1 step -1
if mid$(a$,i,1) = "," then
a$ = left$(a$,i-1) + " and " + mid$(a$,i+2)
exit for
end if
next i
print a$
WEND
You may also check:How to resolve the algorithm Test a function step by step in the jq programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Rust programming language
You may also check:How to resolve the algorithm Old Russian measure of length step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Langton's ant step by step in the Elm programming language