[Community Puzzle] Simplify Selection Ranges

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Can’t find what is wrong for the validator 1 after I have submitted. Can somebody help I passed the other validator

Hi. I have the same problem. Tried it in Perl and in Bash. Both pass all 4 tests but fail Validator1 after submission.

At first I had the same problem as you guys, but then I noticed an error in my solution. It seems that Test 1 and Validator Test 1 are quite different :slight_smile: For me, there was a corner case which was not tested in tests 1-4, but it clearly made my solution not work. Good luck :slight_smile:

Thanks for your advice. But i can’t see the problem. I tested it with empty arrays, an array with all digits from 0-100, unsorted. Can you give us a more precice hint what corner case you missed?

You can usually attack these kinds of problems by generating a number of small, random inputs and checking manually what the outputs should be. So maybe check not a full, dense array or empty array, but something in the middle.

Also, my bug did not compute wrong values, but formatted the output incorrectly.

I don’t know, mb some negative numbers are the reason? Or zero…

I can tell you that all inputs are positive integers.

** HINT: You might want to consider what your code does if there are no contiguous numbers in the input? Try a few self-made examples like this.

  • danBhentschel

The hint with the random generated list was good. I found the bug after a view tries and finally i fixed it. Thx.

Ok I found my problem it really was an edge case when I had less than 3 non contiguous values at the limits of the specs. Thanks all

I have done lots of tests and still I am unable to find any errors to my solution. Can you provide some of your inputs that caused your program to run incorectly ?

Yeah, [1,2,99,100]


AMAZING !!! thx allot :smiley:

Hi! My solution also fails on validator 1, but the cases mentioned above are handled well. I really dont know where to find the issue. :frowning:

Hi, My code is passing all of the tests, and passing validators 1,3,4, but can’t pass two. Does anyone know what the test is for validator 2 or what the solution might be ?

Hi ryanzwe,
I completed this puzzle in C#, validators are most likely fine.
My Idea for this puzzle was to calculate vector of differences for the input vector (diff1) and then another vector of differences in the vector diff1 (diff2). Based on this you can tell if you have beginning of n, n+1, n+2 … series at the i-th position of the input vector.
There are simpler solutions of this problem as well, but this was the nice opportunity to practice Zip method and lambdas in c#.