Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 1 character in body
Source Link
Adalynn
  • 6.2k
  • 1
  • 18
  • 36

APL (Dyalog Classic), 28 bytes

1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞

⎕ML and ⎕IO are both 1,

Try it online!

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,

Try it online!

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,

Try it online!

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.
deleted 1 character in body
Source Link
Adalynn
  • 6.2k
  • 1
  • 18
  • 36

APL (Dyalog Classic), 28 bytes

1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞

⎕ML and ⎕IO are both 1,

Try it online!

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,

Try it online!

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,

Try it online!

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.
Explanation
Source Link
Adalynn
  • 6.2k
  • 1
  • 18
  • 36

APL (Dyalog Classic), 28 bytes

1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞

⎕ML and ⎕IO are both 1,

Try it online!

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,

Try it online!

APL (Dyalog Classic), 28 bytes

1↓∊(( ̄2↓⊢),2↑⌽) ̈' '(,⊂⍨⊣=,)⍞

⎕ML and ⎕IO are both 1,

Try it online!

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.
Source Link
Adalynn
  • 6.2k
  • 1
  • 18
  • 36
Loading

AltStyle によって変換されたページ (->オリジナル) /