+ 29
Challenge - Look and say sequence
In mathematics, the look-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ... To generate a member of the sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example: 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. 1211 is read off as "one 1, one 2, then two 1s" or 111221. 111221 is read off as "three 1s, two 2s, then one 1" or 312211. For more info - https://en.wikipedia.org/wiki/Look-and-say_sequence
23 Answers
+ 11
Task -
Make a code in any language to find the sequence from 1st element to inputted element.
Sample input -
5
Sample Output -
1
11
21
1211
111221
+ 11
Here's my C# implementation! ✌
I think my solution is quite general and I treat the number in the sequence as string instead of integer as it overflows after the 8th term. Happy coding! 😄
https://code.sololearn.com/c33uCTSQMCaD/?ref=app
+ 11
My attempt in java
https://code.sololearn.com/cfrqJW0w1Qnf/?ref=app
+ 7
+ 6
in Python: most difficult job done by itertools module :(
https://code.sololearn.com/cWtXec6j81FM/?ref=app
+ 6
here's my Python code.. 🐍
https://code.sololearn.com/c2WC86HZ1Wc9/?ref=app
+ 6
The late attempt of a noob amateur:
Python: https://code.sololearn.com/cDcmDzi4cREB/
Ruby: https://code.sololearn.com/c797ADtbS3yJ/
+ 5
Read 1 as one 1 and can be written as 1(one) 1 = 11
then 11 = two 1 = 2(two) 1 = 21 then 21 = ....
+ 4
Python Implementation
https://code.sololearn.com/c50Xbi2Usduq/?ref=app
+ 4
This challenge https://www.sololearn.com/Discuss/743988/?ref=app gave me an idea using cpp:
https://code.sololearn.com/cDbVW5OlE5nz/?ref=app
+ 3
my practice on python https://code.sololearn.com/cP3jG3tMlbjF/#py
+ 2
So interesting! :D
+ 2
Here you go. Checks for valid input.
https://code.sololearn.com/cO1854rla0ic/?ref=app
+ 2
https://code.sololearn.com/cB2BYfvAv3vZ/?ref=app
+ 2
Requires 2 numeric inputs, # of iterations & starting value...
https://code.sololearn.com/coXzn6Rd1a4P/?ref=app
+ 1
here a working example in javascript. Wrote it on the mobile phone so i am going to prettify it later :)
https://code.sololearn.com/WV2qkykK7dsH/?ref=app
+ 1
One recursive solution
https://code.sololearn.com/c67o4aJVNkQ9/?ref=app
0
sample input 1
sample output
1
11
0
here is my python solution it includes iconic recursion with a mix of single for loop.
https://code.sololearn.com/cefSElP3WfBr/#py