Problem 42754. Odd elimination
Inspired by Project Euler problem #539
You'll be given a vector from 1 to n;
Going from left to right, remove the first number and every other number afterward until the end of the list.
Repeat the procedure from right to left, removing the right most number and every other number from the numbers left. Continue removing every other numbers, alternating left to right and right to left, until a single number remains.
Example with n=9
1 2 3 4 5 6 7 8 9
2 4 6 8
2 6
6
Solution Stats
Problem Comments
-
1 Comment
Similar to, though simpler than, James's decimation problem: https://www.mathworks.com/matlabcentral/cody/problems/1092-decimation.
Solution Comments
Show commentsProblem Recent Solvers60
Suggested Problems
-
Find the peak 3n+1 sequence value
2499 Solvers
-
Project Euler: Problem 3, Largest prime factor
1432 Solvers
-
Create an n-by-n null matrix and fill with ones certain positions
603 Solvers
-
471 Solvers
-
Back to basics - mean of corner elements of a matrix
416 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!