Problem 1092. Decimation
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
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 CommentsShow comments
Problem Recent Solvers200
Given a window, how many subsets of a vector sum positive
Permute diagonal and antidiagonal
Given a matrix, swap the 2nd & 3rd columns
More from this Author80
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!