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

4 of 4
deleted 6 characters in body
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
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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