Skip to main content
Commonmark migration
Source Link

#J, 26 bytes

J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

ungolfed

[: ,@,./ (0 1 $~ #) ]`(|.@])/. ]

explanation

  • (0 1$~#)]`(|.@])/.] Use Key /. to split the input into the even/odd groups: (0 1$~#) creates the group definition, by repeating 0 and 1 cyclically to the length of the input. We use the gerundial form of Key for its main verb ]`(|.@]), which applies the identity to the first group and reverses the second group: (|.@]).
  • Now that we have the two groups, the odd one reversed, we just zip them together and flatten: ,@,./

Try it online!

#J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

ungolfed

[: ,@,./ (0 1 $~ #) ]`(|.@])/. ]

explanation

  • (0 1$~#)]`(|.@])/.] Use Key /. to split the input into the even/odd groups: (0 1$~#) creates the group definition, by repeating 0 and 1 cyclically to the length of the input. We use the gerundial form of Key for its main verb ]`(|.@]), which applies the identity to the first group and reverses the second group: (|.@]).
  • Now that we have the two groups, the odd one reversed, we just zip them together and flatten: ,@,./

Try it online!

J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

ungolfed

[: ,@,./ (0 1 $~ #) ]`(|.@])/. ]

explanation

  • (0 1$~#)]`(|.@])/.] Use Key /. to split the input into the even/odd groups: (0 1$~#) creates the group definition, by repeating 0 and 1 cyclically to the length of the input. We use the gerundial form of Key for its main verb ]`(|.@]), which applies the identity to the first group and reverses the second group: (|.@]).
  • Now that we have the two groups, the odd one reversed, we just zip them together and flatten: ,@,./

Try it online!

added 460 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

#J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

ungolfed

[: ,@,./ (0 1 $~ #) ]`(|.@])/. ]

explanation

  • (0 1$~#)]`(|.@])/.] Use Key /. to split the input into the even/odd groups: (0 1$~#) creates the group definition, by repeating 0 and 1 cyclically to the length of the input. We use the gerundial form of Key for its main verb ]`(|.@]), which applies the identity to the first group and reverses the second group: (|.@]).
  • Now that we have the two groups, the odd one reversed, we just zip them together and flatten: ,@,./

Try it online!

#J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

Try it online!

#J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

ungolfed

[: ,@,./ (0 1 $~ #) ]`(|.@])/. ]

explanation

  • (0 1$~#)]`(|.@])/.] Use Key /. to split the input into the even/odd groups: (0 1$~#) creates the group definition, by repeating 0 and 1 cyclically to the length of the input. We use the gerundial form of Key for its main verb ]`(|.@]), which applies the identity to the first group and reverses the second group: (|.@]).
  • Now that we have the two groups, the odd one reversed, we just zip them together and flatten: ,@,./

Try it online!

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

#J, 26 bytes

[:,@,./(0 1$~#)]`(|.@])/.]

Try it online!