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 Revisions

2 of 2
added 58 characters in body
mkst
  • 5.3k
  • 13
  • 19

K (oK), (削除) 25 (削除ここまで) 24 bytes

Solution:

,/'(1+a,1_|a:!#x)$\:+,x:

Try it online!

Explanation:

Port of my K4 solution:

,/'(1+a,1_|a:!#x)$\:+,x: / the solution
 x: / save input as x
 , / enlist
 + / flip
 $\: / pad ($) right by each-left (\:)
 ( ) / do this together
 #x / count length of input, e.g. 3
 ! / range 0..length, e.g. 0 1 2
 a: / save as a
 | / reverse it, e.g. 2 1 0
 1_ / drop first, e.g. 1 0
 a, / join to a, e.g. 0 1 2 1 0
 1+ / add 1, e.g. 1 2 3 2 1
,/' / flatten (,/) each (')

Notes:

  • -1 byte thanks to ngn
mkst
  • 5.3k
  • 13
  • 19

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