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

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

05AB1E, (削除) 23 (削除ここまで) (削除) 22 (削除ここまで) 20 bytes

Input taken as height, then width.

F„ -N_N1&l×ばつ'|.ø,

Explanation

F # height number of times do
 N_ # current row == first row
 ~ # OR
 N1<Q # current row == last row
 „ - è # use this to index into " -"
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 .ø # surround the repeated string with the pipe
 , # print with newline

Try it online!

Saved 2 bytes thanks to Adnan Adnan

05AB1E, (削除) 23 (削除ここまで) (削除) 22 (削除ここまで) 20 bytes

Input taken as height, then width.

F„ -N_N1&l×ばつ'|.ø,

Explanation

F # height number of times do
 N_ # current row == first row
 ~ # OR
 N1<Q # current row == last row
 „ - è # use this to index into " -"
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 .ø # surround the repeated string with the pipe
 , # print with newline

Try it online!

Saved 2 bytes thanks to Adnan

05AB1E, (削除) 23 (削除ここまで) (削除) 22 (削除ここまで) 20 bytes

Input taken as height, then width.

F„ -N_N1&l×ばつ'|.ø,

Explanation

F # height number of times do
 N_ # current row == first row
 ~ # OR
 N1<Q # current row == last row
 „ - è # use this to index into " -"
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 .ø # surround the repeated string with the pipe
 , # print with newline

Try it online!

Saved 2 bytes thanks to Adnan

added 201 characters in body
Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164

05AB1E, (削除) 23 (削除ここまで) 22(削除) 22 (削除ここまで) 20 bytes

Input taken as height, then width.

FN_N1<Q~i'F„ -×ばつ'|N_N1&l×ばつ'|.ø,

Explanation

F # height number of times do
 N_N1<Q~i'- N_  # ifcurrent we'rerow on== first orrow
 ~ # OR
 N1<Q  # current row == last row, push "-"
 è ëð} # elseuse pushthis ato spaceindex char
into " -"
 ×ばつ # repeat this char width-2 times
 '| '| # push a pipe
 .ø # surround the repeated string with the pipe
 , , # print with newline

Try it online! Try it online!

Saved 2 bytes thanks to Adnan

05AB1E, (削除) 23 (削除ここまで) 22 bytes

Input taken as height, then width.

FN_N1<Q~i'-×ばつ'|.ø,

Explanation

F # height number of times do
 N_N1<Q~i'- # if we're on first or last row, push "-"
 ëð} # else push a space char
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 .ø # surround the repeated string with the pipe
 , # print with newline

Try it online!

05AB1E, (削除) 23 (削除ここまで) (削除) 22 (削除ここまで) 20 bytes

Input taken as height, then width.

F„ -N_N1&l×ばつ'|.ø,

Explanation

F # height number of times do
  N_  # current row == first row
 ~ # OR
 N1<Q  # current row == last row  - è # use this to index into " -"
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 .ø # surround the repeated string with the pipe
 , # print with newline

Try it online!

Saved 2 bytes thanks to Adnan

added 35 characters in body
Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164

05AB1E, 23(削除) 23 (削除ここまで) 22 bytes

Input taken as height, then width.

F'|N_N1<Q~i'FN_N1<Q~i'-ëð}×ばつ'|J×ばつ'|.ø,

Explanation

F # height number of times do
 '| # push pipe
 N_N1<Q~i'- # if we're on first or last row, push "-"
 ëð} # else push a space char
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
  J, # joinsurround rowthe andrepeated string with the pipe
  , # print with newline

Try it online! Try it online!

05AB1E, 23 bytes

Input taken as height, then width.

F'|N_N1<Q~i'-ëð}×ばつ'|J,

Explanation

F # height number of times do
 '| # push pipe
 N_N1<Q~i'- # if we're on first or last row, push "-"
 ëð} # else push a space char
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
 J, # join row and print

Try it online!

05AB1E, (削除) 23 (削除ここまで) 22 bytes

Input taken as height, then width.

FN_N1<Q~i'-ëð}×ばつ'|.ø,

Explanation

F # height number of times do
 N_N1<Q~i'- # if we're on first or last row, push "-"
 ëð} # else push a space char
 ×ばつ # repeat this char width-2 times
 '| # push a pipe
  # surround the repeated string with the pipe
  , # print with newline

Try it online!

Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164
Loading

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