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
added 613 characters in body
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Jelly, 15 bytes

RØ.ṗŒpFS=ɗƇUƑƇḢ

Try it online!

-1 byte thanks to caird coinheringaahing

RØ.ṗŒpFS=ɗƇUƑƇḢ Main Link; accepts w as the left argument and n as the right argument
R Range; [1, 2, ..., w]
 Ø.ṗ [0, 1] ~ cartesian power ~ ^
 Œp Cartesian Product of ^'s items - this gets all valid triangles of the right size
 ---ɗƇ Keep elements where
 S the sum of
 F the triangle flattened
 = equals (right argument)
 Ƈ Keep elements where
 Ƒ the element is the same when
 U each sub-list is reversed
 Ḣ Get the first such triangle
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

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