[Community Puzzle] Create the longest sequence of 1s

what to do i’m failing the 999 bits test case and the 2 bits validator…

If you time out in the long input, your approach is too slow. Review some earlier posts in this thread to find out better approaches.

If you fail in the very short input, you did not handle edge cases well. Try hard to “invent” some special, extreme but valid cases. Solve them by your program.

1 Like

i’m failing the 9th test case and passing all the others? is it possible for anyone to send me the input for this test case? thanks

Do you mean test case or validator? For test cases you can access them by clicking the button with a list symbol to the left of the PLAY ALL TESTCASES button.

1 Like

Hi. I have already solved this puzzle twice and am now trying to find a third, RegExp-based approach. This JS solution passes but the fourth validator:

var a = readline().replace(

    /1+/g, n => n.length

).replace(

    /(?<=([^0]+))0(?=([^0]+))/g,

    (_, a, b) => `0${+a + +b}0`

).match(/[^0]+/g);

Can someone please tell me what is that very counter example I was looking for? Thanks in advance.

Hi,

It’s not what’s used in the validator but it should help you see where the issue is: 1111111111010111

It sure did. Thanks a lot.

Excellent job, thank you for this code exercise!

Hi,

Sorry I am a beginner in php, just wanted to try it.

I have an error in output, dont know how to pass it. Al the time I have good value required, but plus with an End of line (\n). Someone could help me out?

Seem to be a problem with echo but don’t know how to pass it.

I was writing like this echo “$count\n”; (for me the \n should not be mandatory when we have only one output).

Here the output I have for the case when the string is “00” so the output should be one.

Standart output :

1

Fail

Found:
1End of line (\n)
Expected:
Nothing

Does this help? https://www.codingame.com/forum/t/trailing-lines-are-part-of-the-answer/1777

1 Like

thx a lot, exactly it was the answer to my problem.

Was spending some time thinking about a solution to this problem, I think it’d be cool to make this problem into a more difficult version by increasing the string length. And throwing in some additional test cases