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

deleted 6 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 23 bytes

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€

A monadic Link accepting a list of lines that yields a list of lists of leg lengths and tabletop lengths.

Try it online!

How?

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€ - Link: list of lists of characters, L
="| - L equals '|'? (vectorises)
 μ - new monadic chain - f(X=that)
 Z - transpose X
 ṣ0ドル - split each at zeros
 Ẏ - tighten
 1Ƈ - keep truthy (non-empty) ones
 -> our legs (as lists of 1s)
 Ʋ - last four links as a monad - f(X):
 Ɲ - for neighbours:
 < - less than?
 T€ - truthy indices of each
 F - flatten
 2/ - reduce pairs by:
 r - inclusive range
 -> our tabletops (as lists of positive integers)
 , - pair legs and tabletops
 Ẉ€ - for each: length of each

Jelly, 23 bytes

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€

A monadic Link accepting a list of lines that yields a list of lists of leg lengths and tabletop lengths.

Try it online!

Jelly, 23 bytes

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€

A monadic Link accepting a list of lines that yields a list of lists of leg lengths and tabletop lengths.

Try it online!

How?

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€ - Link: list of lists of characters, L
="| - L equals '|'? (vectorises)
 μ - new monadic chain - f(X=that)
 Z - transpose X
 ṣ0ドル - split each at zeros
 Ẏ - tighten
 1Ƈ - keep truthy (non-empty) ones
 -> our legs (as lists of 1s)
 Ʋ - last four links as a monad - f(X):
 Ɲ - for neighbours:
 < - less than?
 T€ - truthy indices of each
 F - flatten
 2/ - reduce pairs by:
 r - inclusive range
 -> our tabletops (as lists of positive integers)
 , - pair legs and tabletops
 Ẉ€ - for each: length of each
deleted 6 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 3223 bytes

Zṣ0ドルẎ1Ƈa"|z6
="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/a"-;Ç
="|ÇYƲẈ€

A monadic Link accepting a list of lines that yields a list of characters, which shows the parts laid outlists of leg lengths and tabletop lengths.

Try it online! Try it online!

Jelly, 32 bytes

Zṣ0ドルẎ1Ƈa"|z6
<ƝT€Fr2/a"-;Ç
="|ÇY

A monadic Link accepting a list of lines that yields a list of characters, which shows the parts laid out.

Try it online!

Jelly, 23 bytes

="|μZṣ0ドルẎ1Ƈ,<ƝT€Fr2/ƲẈ€

A monadic Link accepting a list of lines that yields a list of lists of leg lengths and tabletop lengths.

Try it online!

deleted 6 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 3532 bytes

Zṣ0ドルẎ1Ƈa"|z6K€Zṣ0ドルẎ1Ƈa"|z6
<ƝT€Fr2/a"-;Ç
Ỵ="|ÇY="|ÇY

A monadic Link accepting a list of lines that yields a list of characters, which shows the parts laid out.

Try it online! Try it online!

Jelly, 35 bytes

Zṣ0ドルẎ1Ƈa"|z6K€
<ƝT€Fr2/a"-;Ç
Ỵ="|ÇY

Try it online!

Jelly, 32 bytes

Zṣ0ドルẎ1Ƈa"|z6
<ƝT€Fr2/a"-;Ç
="|ÇY

A monadic Link accepting a list of lines that yields a list of characters, which shows the parts laid out.

Try it online!

Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading

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