You misunderstood the behaviour of wrapping (which is, arguably, not described precisely). It is not that when going from positive to negative you always end up with 255. You need to wrap through 255 to lower values, if necessary, so -1 becomes 255, -2 becomes 254, and -12 becomes 244.
I've made an attempt at generating random valid inputs. Loops aren't generated due to the complexity of ensuring that they don't loop forever. However, they should serve the purpose of weeding out any hard-coded solutions.
Enabled in this fork
Duplicate of this
You misunderstood the behaviour of wrapping (which is, arguably, not described precisely). It is not that when going from positive to negative you always end up with 255. You need to wrap through 255 to lower values, if necessary, so -1 becomes 255, -2 becomes 254, and -12 becomes 244.
L Q Q c U B N
0 -> 2 -> 4 -> 16 -> (copy = 16) -> 4 -> -12 (=255) -> output 255
expected:<2[44]> but was:<2[55]>
Where did I make a mistake?
Haskell translation
I've made an attempt at generating random valid inputs. Loops aren't generated due to the complexity of ensuring that they don't loop forever. However, they should serve the purpose of weeding out any hard-coded solutions.
python new test framework + random tests are required. updated in this fork
Quite funny kata.
Added in latest fork
python new test framework is required. updated in this fork
Nice!
Could be excellent, but.. returning a const char* is bad c++ practice :-(
This comment is hidden because it contains spoiler information about the solution
Re-raised as an issue.
approved at some point
tests are not very torough in JavaScript either, I had to add a fixed test to invalidate my solution. It needs more test cases like
[857, 85]
Loading more items...