# Conway Sequence puzzle discussion

1 1 1 2 1 1 2 1 1 1 1 1 2 2 1 3 1 2 2 1 1 ...

I might be mistaken, but two tests seem to be broken. The expected outputs here and here have two trailing numbers without space between each.
Whereas in all other tests, (cannot give link due to link limitations) space is given.

This causes the tests to fail because it doesnâ€™t match. Or am I wrong?

6 Likes

You have to consider numbers as a whole, not digits. So when starting with 25 you have to continue with 1 25, not with 1 2 1 5.

15 Likes

I see! I was indeed wrong. Iâ€™ll take a look to solve it a different way then. Thanks!

1 Like

Je ne comprends pas le deuxiĂ¨me test, lâ€™entrĂ©e est L = 1, R = 2â€¦ Alors que dans la ligne 1 il nâ€™y a quâ€™un caractĂ¨reâ€¦

R ne correspond pas Ă  la colonne Ă  afficher, mais au nombre utilisĂ© pour lâ€™initialisation de la suite.
Dans le cas prĂ©sent, si R = 2, alors on a la suite suivante:
2
1 2
1 1 1 2
3 1 1 2
etcâ€¦
Comme L = 1, on doit afficher la premiĂ¨re ligne, soit â€ś2â€ť.

2 Likes

Ok merci beaucoup! Jâ€™avais fait un programme pour la mĂŞme suite en cours mais on avait jamais fait de changement sur lâ€™initialisation. Jâ€™comprends mieux ce qui est demandĂ© maintenant merci.

nice puzzle, somehow Iâ€™ve got confused by the text description in the first run â€śa one 2 followed by a one 1â€ť etc. However, after reading Wikipedia I could start solving it =)

Oh, I didnâ€™t see that.
I already solved it somewhere else and my code is cleaner here (and correct).

Somehow my code isnâ€™t working for high L number. The sequence seems to works fine for a bunch of iteration (like 15 ) then something goes wrong.

Here a capture of what i have (left) and what i should have (right) for the R1 L25 test . Has anyone an idea of what happen ?

OK.

1 Â§ 1
2 Â§ 1 1
3 Â§ 2 1
4 Â§ 1 2 1 1
5 Â§ 1 1 1 2 2 1
6 Â§ 3 1 2 2 1 1
7 Â§ 1 3 1 1 2 2 2 1
8 Â§ 1 1 1 3 2 1 3 2 1 1
9 Â§ 3 1 1 3 1 2 1 1 1 3 1 2 2 1
10 Â§ 1 3 2 1 1 3 1 1 1 2 3 1 1 3 1 1 2 2 1 1
11 Â§ 1 1 1 3 1 2 2 1 1 3 3 1 1 2 1 3 2 1 1 3 2 1 2 2 2 1
12 Â§ 3 1 1 3 1 1 2 2 2 1 2 3 2 1 1 2 1 1 1 3 1 2 2 1 1 3 1 2 1 1 3 2 2 1

It seems all right except the last one.
It should end with 3211.

Didnâ€™t saw that ! Thanks a lot, letâ€™s fix this.

I have exactly the same problem, but i donâ€™t see whyâ€¦ Oo

Fixed it. My problem is i wasnâ€™t ending my algorithm a the last characther but somehow at the next one , and so i was accessing an other part of the memory. So I just added in my loop the condition ( cur_pos < length of the input ) and it solved my problem. Maybe yours is the same.

Thanks Nicolas

Yep, indeed that was itâ€¦ Thank you and good coding !

That was also my problem (starting with 25 and 33 failed). So i basically replaced my StringBuffer array to an integer list array and with a bit of fiddling it was done, working now as expectedâ€¦

Also, interesting to notice that however Conway is always mentioned, but this algorithm is called everywhere Look-and-say sequence.

I tried this one out. My code can calculate all of the examples. But on the 4th and 6th test case , it says my answer is incorrect. The outputed numbers are correct , but in the answers in the description Iâ€™ve noticed there is no space between the last 2 digits.

Iâ€™ve tried hardcoding the answers like that and that worked. But the spec says there should be a space between digits.

Is this an error in the way the code is evaluated ? Or is my code not correct ?

//Update: my mistake , i mistakenly took the input to mean 2 5 an d 3 3 , where it is supposed to be 25 and 33