Problem 44721. Seperate array to small section according to its index position
Given a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.
for example:
n = 3;
v = [0, 1, 2, 3, 4, 5 , 6, 7]
step 1:
O = [0, 2, 4, 6]
E = [1, 3, 5, 7]
so v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}
step 2:
for every element of this cell, wo separate, we can get
v2 = {[0, 4], [2, 6], [1, 5], [3, 7]}
this is the solution, because the number of every element is two.
have fun!
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Project Euler: Problem 7, Nth prime
1720 Solvers
-
807 Solvers
-
Compute a dot product of two vectors x and y
1024 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1972 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
845 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!