Skip to main content
added 333 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

CJam, 7 bytes

{2/ze_}

Pushes a block (the closest thing to an unnamed function) which transforms the top stack element as required.

Test it here.

Explanation

The explanation assumes that the top of the stack is the array [0 1 2 3 4]. The actual values don't affect the computation.

2/  e# Split the array into chunks of two: [[0 1] [2 3] [4]]
z   e# Zip/transpose, which works on ragged arrays: [[0 2 4] [1 3]]
e_  e# Flatten the result: [0 2 4 1 3]

CJam, 7 bytes

{2/ze_}

Pushes a block (the closest thing to an unnamed function) which transforms the top stack element as required.

Test it here.

CJam, 7 bytes

{2/ze_}

Pushes a block (the closest thing to an unnamed function) which transforms the top stack element as required.

Test it here.

Explanation

The explanation assumes that the top of the stack is the array [0 1 2 3 4]. The actual values don't affect the computation.

2/  e# Split the array into chunks of two: [[0 1] [2 3] [4]]
z   e# Zip/transpose, which works on ragged arrays: [[0 2 4] [1 3]]
e_  e# Flatten the result: [0 2 4 1 3]
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

CJam, 7 bytes

{2/ze_}

Pushes a block (the closest thing to an unnamed function) which transforms the top stack element as required.

Test it here.