Conway Sequence puzzle discussion

Feel free to send your feedback or ask some help here!

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.

17 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! :slight_smile: 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 =)

http://rosettacode.org/wiki/Look-and-say_sequence

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 ?

https://drive.google.com/open?id=0B8blPvNVNa5HbG8wbkVwNEh1Q1U&authuser=0

OK.
Can you please post your answers before this big one, for example the first ones?

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 :wink:

Yep, indeed that was it… Thank you and good coding ! :stuck_out_tongue:

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