Problem 1092. Decimation
Solution Stats
Problem Comments
-
8 Comments
I seem to get 1773 for test case 6.
I also get 1773 for test case 6
I'll look into it a bit later on. In the meantime, that test case is deleted, so you can see if your solutions work for the rest of the test cases.
An interesting test case would have kill_every=1.
Am I the only one who finds the problem description really lacking? WTF does it mean "Because Prisoner 10 was counted during the first iteration,..." IMHO this is just blah and not a well-defined problem definition...
At least 2 of the test cases do not match what I find if I run the sequence by hand on paper. Specifically:
num_prisoners = 30; kill_every = 5;
Survivor is prisoner number 14, not number 3
and,
num_prisoners = 10; kill_every = 10;
Survivor is prisoner number 6, not number 8
Based on other comments, it looks like the test cases may have changed at some point. I believe at least these two (and likely a couple others) are now incorrect.
@Christopher Lanning, decimate(10, 10) = 8 is correct; perhaps you made a mistake on paper. When doing this by hand, it's easiest to count kill_every steps, wrapping around at the end of the line and skipping over crossed-out entries (think Eeny Meeny Miny Moo). Prisoner 6 gets killed in the 4th iteration.
Also, I agree with Andrew Newell's earlier comment that there should be a test case for kill_every = 1.
Solution Comments
Show commentsProblem Recent Solvers200
Suggested Problems
-
Return the 3n+1 sequence for n
7584 Solvers
-
3033 Solvers
-
Find third Side of a right triangle given hypotenuse and a side. No * - or other functions allowed
173 Solvers
-
203 Solvers
-
Find out sum and carry of Binary adder
1079 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!