Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Python: Look and Say: There is a particular sequence named 'Look and Say' sequence. The sequence begins with a single digit in which the

Use Python: Look and Say:
There is a particular sequence named 'Look and Say' sequence. The sequence begins
with a single digit in which the next term is obtained by describing the previous term. For
example, we start the sequence with number 1 and then we pronounce the number
correctly. As for the number 1, It must be read as "one 1," where "one" represents the
total digits of that number. We write the "one 1" numerically and we get the number 11.
Next we can read 11 as "two 1." So the next number of this sequence is 21. We read 21 as
"one 2, one 1". So the next number of this sequence is 1211. Thus the sequence is: 1,11,
21,1211[read as one 1, one 2, two 1],111221,....
You are given a number where the digits are the elements of a numpy array. Write a
method that generates the next number in the look and say sequence and stores it in a new
array.
Constraint: You cannot use any other datatype [i.e. string] or data structure except for
arrays.
Hint: The size of the new array will never be more than 100.
[You need not worry about the extra zeroes at the end of your resulting array]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions