Suppose we have the list for $n\in\mathbb{N}$

  1. We choose the number in the list where $x=1$, $x=n$ and $x=1+(n-1)/2$ round closest to and the numbers closest to the chosen elements.

For instance, if $n=15$ the elements rounded closest to are boxed, and the elements closest to the chosen elements are underlined.


  1. Next we choose the numbers are not in the previous sub-list and round closest to $x=1+(n-1)/4$ and $x=1+3(n-1)/4$ (which are double boxed) and elements closest to the double boxed, underlined and single boxed numbers (which are double-underlined)


For values of larger $n$, we continue this. In general, for $r\in\mathbb{N}$, we choose elements that $x=1+(n-1)/2^r$,$x=1+2(n-1)/2^r$...,$x=1+(2^r-1)(n-1)/2^r$ round closest to and aren't in previous iterations; then, choose elements closest to these and those from previous iterations till we have no more elements left.


For a larger list such as $n=100$, what would this list look like? For example, for $n=15$, the list of sub-lists would look like.


Edit: Here is the code that I have tried

From a previous answer, I know that for each iteration, the boxed numbers can be found using the following:

n = 100;(*length of original list*)
d = Range[1, n];
get[m_, n_] := 
  Module[{}, Round[1 + (n - 1) Table[2 i - 1, {i, 1, 2^m/2}]/2^m]];
t = {1, get[1, n][[1]], n};
res = {t};
d = Select[d, ! MemberQ[t, #] &];
sel[m_, d_, n_] := Module[{t}, t = get[m, n];
   {Select[d, MemberQ[t, #] &], Select[d, ! MemberQ[t, #] &]}];
i = 2; While[d != {}, 
 If[i > Length[d], Break[]]; {t, d} = sel[i++, d, n];
 Print[{d, t}]; AppendTo[res, t]]

Where res takes the list of boxed numbers until all values are taken.

Unfortunately, I know little about the code (e.g. whileloop,++,break) to modify it so for each iteration, I can choose numbers closest to the boxed number, as well as the others values from previous iterations.

  • 2
    $\begingroup$ In the output,where is 4? $\endgroup$
    – cvgmt
    Jan 21 at 23:10
  • $\begingroup$ @cvgmt My bad. I added it. $\endgroup$
    – Arbuja
    Jan 22 at 0:51
  • $\begingroup$ Include code of what you have tried. $\endgroup$
    – Edmund
    Jan 22 at 2:13
  • $\begingroup$ @Edmund I gave code from a previous answer but I'm not sure what else to use. $\endgroup$
    – Arbuja
    Jan 22 at 2:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.