Array Transformation
Introduction
Suppose that you have an array of sorted integers that are numbered from 12 laid out horizontally. A transformation NI. be performed on this array where it is split in half vertically, and the leftmost values are placed on top of the rightmost values. This stacking transformation Miff be repeated on the result of the previous transformation until the resulting array is a single column of values.
Problem
Write a function that returns the array in the appropriate order after the stacking transformation takes place. The input to this function is an array of sequential integers, numbered from 1 to 2^n.
Approach:
There are plenty of way of going about this problem. I wouldnt doubt if there is a sequence that generates this recursive-like problem.
Properties: 2^n is always even, the sequence generated is symetric.
I decided to use iterators to continuously split the arrays untill they are of size 1.
Last updated