How to resolve the algorithm Look-and-say sequence step by step in the TUSCRIPT programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Look-and-say sequence step by step in the TUSCRIPT programming language
Table of Contents
Problem Statement
The Look and say sequence is a recursively defined sequence of numbers studied most notably by John Conway.
The look-and-say sequence is also known as the Morris Number Sequence, after cryptographer Robert Morris, and the puzzle What is the next number in the sequence 1, 11, 21, 1211, 111221? is sometimes referred to as the Cuckoo's Egg, from a description of Morris in Clifford Stoll's book The Cuckoo's Egg.
Sequence Definition
An example:
Write a program to generate successive members of the look-and-say sequence.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Look-and-say sequence step by step in the TUSCRIPT programming language
Source code in the tuscript programming language
$$ MODE TUSCRIPT,{}
num=1,say=""
LOOP look
digits=STRINGS (num," ? ")
digitgrouped=ACCUMULATE (digits,howmany)
LOOP/CLEAR h=howmany,digit=digitgrouped
say=JOIN (say,"",h,digit)
ENDLOOP
PRINT say
num=VALUE(say),say=""
IF (look==14) EXIT
ENDLOOP
You may also check:How to resolve the algorithm Calendar step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the Draco programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Go programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Clio programming language
You may also check:How to resolve the algorithm Sequence: smallest number greater than previous term with exactly n divisors step by step in the C programming language