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 15 characters in body
Source Link
bxm
  • 261
  • 2
  • 4

Dash*, 69 bytes

seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g

Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.

Try it online!

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

for p in `seq -- -8 8`;do seq -s"`printf "%${p}s_"`" 10;done|sed s/_1*//g

Try it online!

Explanation (for method)

for p in `seq -- -8 8`

Produce -8 to 8, used to create separator in next seq. NB BusyBox’sBusyBox’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 doesn't matter

EDIT: scraped off another few bytes by ditching the for in favour of xargs.

*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 minimallimited to -w and -s.

Dash*, 69 bytes

seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g

Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.

Try it online!

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

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 doesn't matter

EDIT: scraped off another few bytes by ditching the for in favour of xargs.

*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.

Dash*, 69 bytes

seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g

Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.

Try it online!

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

for p in `seq -- -8 8`;do seq -s"`printf "%${p}s_"`" 10;done|sed s/_1*//g

Try it online!

Explanation (for method)

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 doesn't matter

EDIT: scraped off another few bytes by ditching the for in favour of xargs.

*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 limited to -w and -s.

added 464 characters in body
Source Link
bxm
  • 261
  • 2
  • 4

Dash*, 69 bytes

seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g

Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.

Try it online!

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 doesn't matter

EDIT: scraped off another few bytes by ditching the for in favour of xargs.

*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.

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 doesn't matter

Dash*, 69 bytes

seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g

Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.

Try it online!

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

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 doesn't matter

EDIT: scraped off another few bytes by ditching the for in favour of xargs.

*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.

added 6 characters in body
Source Link
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.

EDIT: saved many bytes because negative padding printf doesn't matter

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.

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 doesn't matter

added 87 characters in body
Source Link
bxm
  • 261
  • 2
  • 4
Loading
deleted 102 characters in body
Source Link
bxm
  • 261
  • 2
  • 4
Loading
removed a silly space (thanks Kevin Cruijssen)
Source Link
bxm
  • 261
  • 2
  • 4
Loading
removed a silly space (thanks Kevin Cruijssen)
Source Link
bxm
  • 261
  • 2
  • 4
Loading
added 6 characters in body
Source Link
bxm
  • 261
  • 2
  • 4
Loading
Source Link
bxm
  • 261
  • 2
  • 4
Loading

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