APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the lastfirst element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the first element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ⍞... the input ...... ' ' ...... at spaces.... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.1↓∊ ...Finally, return all but the last element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.
APL (Dyalog Classic), 28 bytes
1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞
⎕ML and ⎕IO are both 1,
Explanation
... (,⊂⍨⊣=,) ...Split (while keeping borders, and appending a border to the beginning) ...... ⍞... the input ...... ' ' ...... at spaces.... ( ... ) ̈ ...Then, to each element of that:... , ...Concatenate ...... ( ̄2↓⊢) ...... every item except the last two ...... 2↑⌽ ...... with the reverse of the last two elements.1↓∊ ...Finally, return all but the last element of the flattened result.