g | x | w | all
Bytes Lang Time Link
007Uiua SBCS240612T153444Zchunes
076R240612T150558Zint 21h
003Thunno 2230816T120338ZThe Thon
050Python 2170527T132636ZRod
003Vyxal210120T045516Zlyxal
00705AB1E210120T072932Zovs
006Japt170830T102204ZShaggy
027Perl180201T185036ZTon Hosp
084Jq 1.5171014T005449Zjq170727
026J171013T201738ZJonah
018K oK171013T144542Zmkst
01205AB1E170831T123425Zscottine
027q/kdb+170529T095421Zmkst
009APL Dyalog170528T110847ZAdá
02105AB1E170613T202545ZMagic Oc
013Japt170528T054435ZOliver
082Mathematica170527T143917ZDELETE_M
nanPerl 5170530T002518ZChris
024GNU APL 1.2170529T084444ZArc676
069C170528T190521ZQuentin
1713Retina170527T154501ZFryAmThe
063Haskell170528T142644ZLaikoni
024APL Dyalog170528T110008Zuser4180
062Mathematica170527T210514ZZaMoC
nan170527T191520ZBrad Gil
007Jelly170527T152755ZDennis
009Jelly170527T151214Zhyper-ne
070OCaml170527T153339Zjuloo65
093Java OpenJDK 8170527T095540Zuser4180
067Python 2170527T111926Zovs
048JavaScript ES6170527T104654ZNeil
058PHP>=7.1170527T104024ZJör
010Alice170527T103716ZLeo
034Röda170527T102405Zuser4180
008MATL170527T100453ZLuis Men
087Python 3170527T100706ZTrelzevi
032Octave170527T100525Zrahnema1

Uiua SBCS, 7 bytes

⍜▽⇌◿2°⊏

Try it!

⍜▽⇌◿2°⊏­⁡​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌­
   ◿2°⊏  # ‎⁡mask of odd indices
⍜▽⇌      # ‎⁢reverse according to mask

R, 76 bytes

\(S)cat(substring(S,s<-ifelse((a=1:(n=nchar(S)))%%2,a,n-n%%2+2-a),s),sep="")

Attempt This Online!

In this solution I have used a vector of the characters positions from 1 to the length of the input string. The even numbers in this vector are swapped with their counterparts, the odd positions are kept in their place.

This numeric vector is then fed to the substring function, which produces the vector of the corresponding characters in a single call.

Thunno 2, 3 bytes

^rI

Try it online!

Explanation

     # Implicit input

^    # Uninterleave into two parts and push them separately to the stack
     #   "Hello, World!"  ->  "Hlo ol!", "el,Wrd"
     #   "ABCDEF"         ->  "ACE", "BDF"
     #   "P"              ->  "P", ""

 r   # Reverse the top of stack (second part from before)
     #   "Hello, World!"  ->  "Hlo ol!", "drW,le"
     #   "ABCDEF"         ->  "ACE", "FDB"
     #   "P"              ->  "P", ""

  I  # Interleave the two strings together
     #   "Hello, World!"  ->  "HdlroW ,olle!"
     #   "ABCDEF"         ->  "AFCDBE"
     #   "P"              ->  "P"

     # Implicit output

Python 2, 52 50 bytes

-2 bytes (and a bug fix) thanks to pxeger

s=bytearray(input())
s[1::2]=s[1::2][::-1]
print s

Try it online! or Try all test cases

Vyxal, s, 3 bytes

yṘY

Try it Online!

Turns out by making my answer valid I saved a byte. Oh the irony

Explained

yṘY
y      # un-interleave
 Ṙ     # reverse
  Y    # re-interleave

05AB1E, 7 bytes

ι and have been added since this challenge was posted, both of them save bytes here.

Sι`R.ιJ

Try it online!

If we were allowed to take a list of string of length 1, ι`R.ι would work for 5 bytes.

S         # split the string into a list of characters
 ι        # uninterleave: push [even indices, odd indices]
  `       # push both values seperately to the stack
   R      # reverse the odd indices
    .ι    # interleave the two lists
      J   # join into a string

Japt, 8 6 bytes

ó oÔrí

Try it

ó oÔrí     :Implicit input of string
ó          :Uninterleave
  o        :Modify last element
   Ô       :  Reverse
    r      :Reduce by
     í     :  Interleaving

Perl, 27 bytes

Includes +5 for -F lp

perl -F -lpe 's/.\K./$F[@F%-2-pos]/g' <<< "abcdefghi"

If you give STDIN without newline you can drop the l option

Jq 1.5, 84 bytes

[_nwise(2)|[_nwise(1)]]|transpose|map(map(values))|.[1]|=reverse|[transpose[][]]|add

Expanded

   [_nwise(2)|[_nwise(1)]] # make list of two character lists
 | transpose               # convert to list of two lists of characters
 | map(map(values))        # discard null
 | .[1] |= reverse         # reverse second list
 | [transpose[][]]         # transpose back to two lists and flatten
 | add                     # convert back to string

Try it online!

J, 26 bytes

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

ungolfed

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

explanation

Try it online!

K (oK), 18 bytes

Solution:

{x[w:&2!!#x]:x@|w}

Try it online!

Examples:

> {x[w:&2!!#x]:x@|w}"Hello, World!"
"HdlroW ,olle!"
> {x[w:&2!!#x]:x@|w}"Hello World!"
"H!llooW rlde"

Explanation:

Interpretted mostly right-to-left, find the odd-indices characters, reverse them and put them back into the string

{x[w:&2!!#x]:x@|w} / solution
{                } / lambda function with implicit parameter x
         #x        / count x,    #"Hello, World!" -> 13
        !          / til,        !13 -> 0 1 2 3 4 5 6 7 8 9 10 11 12
      2!           / 2 modulo,   2!0 1 2 3 4 5 6 7 8 9 10 11 12 -> 0 1 0 1 0 1 0 1 0 1 0 1 0
     &             / where true, @0 1 0 1 0 1 0 1 0 1 0 1 0 -> 1 3 5 7 9 11
   w:              / store in variable w
               |w  / reverse w,  |1 3 5 7 9 11 -> 11 9 7 5 3 1
             x@    / index into x at these indices
 x[        ]:      / assign right to x at these indices

05AB1E, 12 bytes

RDgÈúøvyNÉè?

Try it online!

RDgÈúøvyNÉè?   Implicit input: "abcdefghij"
R              Reverse the string: "jihgfedcba"
 DgÈú          Put (length is even?1:0) spaces in front of it " jihgfedcba"
     ø         Zip (reinjects the input implicitly): ["a ", "bj", "ci", ...]
      vy       For each element of the list
        NÉè    Extract&push element[iteration is odd?1:0] 
           ?   Print without newline

q/kdb+, 70 56 47 38 35 29 27 bytes

Solution:

{x[w]:x(|)w:(&)#:[x]#0 1;x}

Example:

q){x[w]:x(|)w:(&)#:[x]#0 1;x}"Hello, World!"
"HdlroW ,olle!"
q){x[w]:x(|)w:(&)#:[x]#0 1;x}"Hello World!"
"H!llooW rlde"

Explanation:

Find the odd indices of the string, reverse this list, pull out elements at these points and then reassign them in-place to the original string.

{x[w]:x reverse w:where count[x]#0 1;x} / ungolfed
{                                   ; } / lambda function with two lines
                                 0 1    / the list (0;1)
                                #       / take
                        count[x]        / length of input
                  where                 / indices where this is > 0
                w:                      / save in variable w
        reverse                         / reverse this list
      x                                 / index into x at these points
     :                                  / assignment             
 x[w]                                   / assign x at indices with new values
                                     x  / return x

Edits:

APL (Dyalog), 9 bytes

Requires ⎕IO←0 (default on many systems) for proper definition of odd and even.

⌽@{2|⍳≢⍵}

Try it online!

 reverse

@ at the elements filtered by the mask result from applying the

{ anonyomous function

2| the mod-2 of

 the indices of

 the tally (length) of

 the argument

} on the argument

05AB1E, 21 bytes

DgÉi¶«}2ô.BøRćR‚˜øJ¶K

Try it online!

I'm guessing the reason this wasn't done in 05AB1E yet is because it's gross...

Yet another time the zip function's auto-drop-last-element hurts instead of helps.

P.S. If you have improvement suggestions on my answer, post your own; it's likely enough of an improvement to warrant you getting the points. I am pretty ashamed of this answer.

Japt, 14 13 bytes

12 bytes of code, +1 for the -P flag.

Saved 1 byte thanks to @Shaggy

¬ë íU¬Åë w)c

Explanation:

¬ë íU¬Åë w)c
¬                   Split the input into an array of chars
 ë                  Get every other char, starting at index 0
   í                Pair with:
    U¬                Input, split into a char array
      Å               .slice(1)
       ë              Get every other char
         w            Reverse
           c       Flatten
-P                 Join into a string

Try it online!

Mathematica, 82 bytes

""<>(f=Flatten)[{#&@@#,Reverse@Last@#}&@f[Characters@#~Partition~UpTo@2,{2}],{2}]&

Perl 5, 46 + 3 for -F flag = 49 bytes

while(++$x<@F){print$F[$x%2?$x-1:@F-$x-$#F%2]}

Uses the -F flag to auto split the input into an array of characters, @F. Loops through the array and outputs that element for an even index or that index (plus one for an odd length string) from the end for an odd input.

Takes input with a trailing newline. Without the trailing newline, can just change the pre-increment on $x to a post-increment.

A little more readable:

while(++$x<@F) { #While the index is less than the number of elements in the array. $x is 1-indexing the array despite the fact that perl is 0-indexed because it keeps us from having to use a proper for loop or a do-while loop
    if($x%2) { #If $x is odd
        print $F[$x-1] #Print the element
    } else {
        print $F[@F-$x-$#F%2] #Print from the end. $#F%2 fixes it for odd length strings    
    }
}

GNU APL 1.2, 24 bytes

R[X]←⌽R[X←2×⍳⌊.5×⍴R←⍞]◊R

APL works from right to left. ⍴R←⍞ assigns user input to R and then evaluates its length. Halve this by multiplying by .5 and apply floor function. returns all numbers from 1 to the argument.

APL operates on arrays, so the array we just got from doubles each element, giving us just the even indices (1-indexed, so relies on ⎕IO being 1).

When accessing multiple indices of a vector, APL gives the elements at those indices in a vector. R[X←2×⍳⌊.5×⍴R←⍞] gives just the even-indexed elements. reverses the elements. Then, assign the reversed values back to the even indices (assigning these indices to X saves 6 bytes).

is the statement separator. After the reversing is done, evaluate R to print the result.

C, 69 bytes

c,l;f(char*s){l=strlen(s);for(c=0;c<l;++c)putchar(s[c&1?l-l%2-c:c]);}

Pretty simple. Walks the string, printing either the current character or the opposite one.

Ungolfed and explained:

f(char *str) {
    int len = strlen(str);      // Get the total length
    for(int c = 0; c<len; ++c)  // Loop over the string
        putchar(s[              // Print the char that is,
            c & 1               // if c is odd,
                ? l - l % 2 - c // c chars from the end (adjusting odd lengths),
                : c             // and at index c otherwise
        ]);
}

Retina, 17 13 bytes

O^$`(?<=\G.).

Try it online!

Fixed an error thanks to Neil.

Saved 4 bytes thanks to Kobi.

Selects each letter preceded by an odd number of characters and reverses them. Does this by using \G which matches the end of the last match.

Haskell, 63 bytes

(_:r)!(a:s)=a:s!r
_!_=[]
f s=([' '|even$length s]++reverse s)!s

Try it online! Usage: f "some string".

For odd strings like abcdefghi, the function f passes the string and its reversal to the function !, which alternates taking chars from both strings. For even strings this does not work, and we need to append a dummy character first to get the offset right.

APL (Dyalog), 24 bytes

Bytes golfed thanks to @Adám

A⊣A[i]←⌽A[i←2×⍳⌊2÷⍨⍴A←⎕]

Try it online!

Mathematica, 62 bytes

takes as input a string

(s=Characters@#;Row@Riffle[s[[;; ;;2]],Reverse@s[[2;; ;;2]]])&

Try it online!

Perl 6,  63 58  55 bytes

{[~] .comb[{flat roundrobin (0,2...^*>=$_),[R,] 1,3...^*>=$_}]}

Test it

{[~] flat roundrobin .comb[{0,2...*},{$_-1-$_%2,*-2...*}]}

Test it

{[~] flat roundrobin .comb[{0,2...*},{[R,] 1,3...^$_}]}

Test it

{  # bare block lambda with implicit parameter 「$_」

  [~]                 # reduce using string concatenation operator

    flat              # make the following a flat list

    roundrobin        # grab one from each of the following 2 lists,
                      # repeat until both are empty

    .comb\            # split the input into graphemes (implicit method call)

    [                 # index into that sequence



      { 0, 2 ... * }, # code block producing every non-negative even number


      {               # code block producing reversed odd numbers
                      # (「$_」 here contains the number of available elements)

        [R,]          # reduce with reversed comma operator
                      # (shorter than 「reverse」)

        1, 3 ...^ $_  # odd numbers stopping before it gets
                      # to the number of input elements
      }


    ]
}

I had to use roundrobin rather than zip, because zip stops as soon as one of the input lists is exhausted.

Jelly, 7 bytes

s2ZU2¦Z

This is a full program.

Try it online!

How it works

s2ZU2¦Z  Main link. Argument: s (string)

s2       Split s into pairs.
  Z      Zip/tranpose, grouping characters by the parity of their indices.
     ¦   Sparse application:
   U         Upend; reverse both strings in the pair.
    2        Replace the second string with the reversed string.
      Z  Zip/transpose, interleaving the two strings.

Jelly, 9 bytes

Ḋm2U
m2żÇ

Try it online!

Ḋm2U Helper Link -> Dequeue (return last len-1 elements), take every second element, reverse
m2żÇ Main Link -> Take every second element, then interleave with the result of the helper link

-1 byte thanks to Dennis

OCaml, 70 bytes

let f s=String.(mapi(fun i c->s.[(length s land-2-i-i)*(i mod 2)+i])s)

Try it online!

Java (OpenJDK 8), 108 96 94 93 bytes

Saved 1 byte by using @Neil's neat trick of using s[s.length+~i|1]

String f(char[]s){int a=s.length,b=0;String c="";for(;b<a;b++)c+=s[b%2<1?b:a+~b|1];return c;}

Try it online!

Python 2, 67 bytes

lambda s,j=''.join:j(map(j,zip(s[::2]+' ',s[1::2][::-1]+' ')))[:-1]

Try it online!

JavaScript (ES6), 48 bytes

f=
s=>s.replace(/./g,(c,i)=>i%2?s[s.length+~i|1]:c)
<input oninput=o.textContent=f(this.value)><pre id=o>

PHP>=7.1, 58 Bytes

for(;$i<$l=strlen($a=$argn);$i++)echo$a[$i&1?-$i-$l%2:$i];

Online Version

Alice, 10 bytes

/ZY
\IOR@/

Try it online!

Half of the bytes of this program are spent on correctly formatting the source, the actual commands are just IYRZO, because Alice has just the right builtins for this task.

Explanation

As I said, the mirrors (/\), the newline and @ are there just to make the ip move in the right direction and terminate the program at the end. The actual code, linearised, is the following:

IYRZO
I      Input a line
 Y     Unzip it into its even positions and its odd ones
  R    Reverse the odd positions
   Z   Zip it back again
    O  Output

Quite straightforward, I'd say.

Röda, 34 bytes

f a{a/=""a[::2]<>reverse(a[1::2])}

Try it online!

Explanation

a/=""                    Convert the argument a into an array of length-1 strings
      <>                 Interleave
a[::2]                   Every even element of a with
        reverse(a[1::2]) Every odd element of a reversed

Here is an alternative solution at the same bytecount

36 34 bytes

{[_/""]|_[::2]<>reverse(_1[1::2])}

This is an anonymous function that takes input as a string from the input stream.

MATL, 8 bytes

t2L)P5M(

Try it online! Or verify all test cases.

Explanation

t     % Implicit input. Duplicate
      % STACK: 'abcdefghi', 'abcdefghi'
2L    % Push [2, 2, 1j]. This represents 2:2:end when used as an index
      % STACK: 'abcdefghi', 'abcdefghi', [2, 2, 1j]
)     % Get entries at those indices
      % STACK: 'abcdefghi', 'bdfh'
P     % Flip
      % STACK: 'abcdefghi', 'hfdb'
5M    % Push [2, 2, 1j] again
      % STACK: 'abcdefghi', 'hfdb', [2, 2, 1j]
(     % Write entries at those indices. Implicit display
      % STACK: 'ahcfedgbi'

Python 3, 93 87 bytes

lambda s:"".join("".join(t)for t in zip(s[::2],reversed(s[1::2])))+("",s[-1])[len(s)%2]

Octave, 32 bytes

@(a,b=a(x)=a(flip(x=2:2:end)))a;

Try it online!