+ 10
Yet another coding challenge (#6)
Look at my answer for explanation. Your program should either: a) Have the user enter a number n and print the first n numbers of the look-and-say sequence b) Have the user enter a number n and print the next number in the look-and-say sequence (for example, input = 8482739 would generate 18141812171319) c) Have the user enter 2 numbers n and m and generate the first m numbers of a look-and-say sequence starting with n (for example: n = 3, m = 5 would be 3, 13, 1113, 3113, 132113 etc)
4 Respostas
+ 9
The look-and-say sequence defines as follows:
Start with 1.
Speak "one 1" (11)
Speak "two 1's" (21)
Speak "one 2, one 1" (1211)
Speak "one 1, one 2, two 1" (111221)
etc.
+ 14
Here's mine:
https://code.sololearn.com/cfL7rbMawlf8/?ref=app
+ 9
@Tobi nice code, but changing the number to something only a bit higher (I just tried 25) exceeds the time limit... can you make it faster?
@Jafca nice code, works perfectly!
+ 3
Yay, a nontrivial use of reduce:
https://code.sololearn.com/c5jRqKHGvsUR/?ref=app