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 58 characters in body
Source Link
mkst
  • 5.3k
  • 13
  • 19

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

Solution:

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

Try it online! Try it online!

Explanation:

Port of my K4 solution:

,/'(1+a,1_|a:!#x)$\:+,:'xx: / the solution
 x: / save input as x
 ,:' / enlist (,:) each (') + / 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

K (oK), 25 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 (,:) each (')
 $\: / 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 (')

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
Source Link
mkst
  • 5.3k
  • 13
  • 19

K (oK), 25 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 (,:) each (')
 $\: / 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 (')

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