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

6 of 9
added 87 characters in body
bxm
  • 261
  • 2
  • 4

Dash*, (削除) 87 (削除ここまで), (削除) 86 (削除ここまで), 73 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 -- -8 8`;do seq -s"`printf "%${p}s_"`" 10;done|sed s/_1*//g

Try it online!

Explanation

for p in `seq -- -8 8`

Produce -8 to 8, used to create separator in next seq. NB BusyBox’s seq barfs on the -8 without the -- but TIO’s Dash env does not.

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

Print 1-10, separated with p ×ばつ spaces, with an extra _ appended (because seq won't accept an empty separator).

;done|sed s/_1*//g

Remove the _ as well as the 1 from trailing 10.

EDIT: removed a silly space (thanks Kevin Cruijssen) *EDIT: saved many bytes because negative padding printf works fine.

bxm
  • 261
  • 2
  • 4

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