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

edited body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 64(削除) 64 (削除ここまで) 62 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→|¦#|θFθFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FEυ⌕A⭆θ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ|¦#|θ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυFΦ⪪ι#λ«FθFΦ⪪ι#λ«

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#FEυ⌕A⭆θ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

Charcoal, 64 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυFΦ⪪ι#λ«

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

Charcoal, (削除) 64 (削除ここまで) 62 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|θFθFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FEυ⌕A⭆θ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|θ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FθFΦ⪪ι#λ«

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FEυ⌕A⭆θ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

fix to explanation
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 64 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυF+Φ⪪ι#λ «FυFΦ⪪ι#λ«

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

Charcoal, 64 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυF+Φ⪪ι#λ «

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

Charcoal, 64 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυFΦ⪪ι#λ«

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 64 bytes

WS⊞υι≔Eθ⪫⪪⭆υ§λκ-|¦#|υFυFΦ⪪ι#λ«P↓Noκ|→→»←⸿⸿FE§υ0⌕A⭆υ§λκ#Wι«⊕−⊟ι⊟ι→

Try it online! Link is to verbose version of code. Takes input as a rectangular list of newline-terminated strings. Explanation:

WS⊞υι

Input the stack of tables.

≔Eθ⪫⪪⭆υ§λκ-|¦#|υ

Transpose the stack and identify the ends of the tabletops i.e. those parts above the legs.

FυF+Φ⪪ι#λ «

For each column of the original stack split it on tabletop ends, dropping the first element (which is the space above the first end) and loop over the resulting legs.

P↓Noκ|→→

Print the length of the leg vertically (which Charcoal automatically translates into a line of |s) without moving the cursor and then allow two columns for the next leg.

»←⸿⸿

Move up to the start of the previous row but one.

FE§υ0⌕A⭆υ§λκ#

Transpose the stack back and find all of the tabletop ends.

Wι«⊕−⊟ι⊟ι→

Loop over the ends in pairs, print the inclusive difference between each pair (which Charcoal automatically translates into a line of -s) and then allow a column for the next tabletop.

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