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

4 of 9
removed a silly space (thanks Kevin Cruijssen)
bxm
  • 261
  • 2
  • 4

Dash*, (削除) 87 (削除ここまで) 86 bytes

*Actually this is aimed at Busybox 1.31.1 ash, sed, seq and printf, but TIO didn't have that environment. NB available seq options are pretty minimal.

for p in `seq 9 -1 2;seq 9`;do seq -s"`printf "%${p}s_"`" 10;done|sed s/10/0/\;s/._//g

Try it online!

Explanation

for p in `seq 9 -1 2;seq 9`

Produce 9-2, 1-9, used to create separator in next seq

;do seq -s"`printf "%${p}s_"`" 10

Print 1-10, separated with p ×ばつ spaces, with marker _ appended; results in 1 too many spaces (but seq won't accept an empty separator), the marker _ helps us to remove the spare spaces below.

;done|sed s/10/0/\;s/._//g

Remove the 1 from trailing 10, remove the marker _ and the extra space before it, to get the proper spacing.

EDIT: removed a silly space (thanks Kevin Cruijssen)

bxm
  • 261
  • 2
  • 4

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