+ 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)

30th Apr 2017, 9:29 AM
Supersebi3
Supersebi3 - avatar
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.
30th Apr 2017, 9:30 AM
Supersebi3
Supersebi3 - avatar
30th Apr 2017, 2:51 PM
Jafca
Jafca - avatar
+ 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!
30th Apr 2017, 3:44 PM
Supersebi3
Supersebi3 - avatar
+ 3
Yay, a nontrivial use of reduce: https://code.sololearn.com/c5jRqKHGvsUR/?ref=app
30th Apr 2017, 10:58 AM
Tob
Tob - avatar