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

added 613 characters in body
Source Link
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

Jelly, 15 bytes

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

Try it online!

-1 byte thanks to caird coinheringaahing

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
deleted 43 characters in body
Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Jelly, 1615 bytes

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

Try it online! Try it online!

Finds a valid solution by brute force. Waiting for caird-1 byte thanks to outgolf me by 50%.caird coinheringaahing

Jelly, 16 bytes

RØ.ṗŒpFS=9ƲƇUƑƇḢ

Try it online!

Finds a valid solution by brute force. Waiting for caird to outgolf me by 50%.

Jelly, 15 bytes

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

Try it online!

-1 byte thanks to caird coinheringaahing

deleted 16 characters in body
Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227

Jelly, 1916 bytes

RSr_\ṖṬŒ!ṁ8ドルRR¤UƑƇḢRØ.ṗŒpFS=9ƲƇUƑƇḢ

Try it online! Try it online!

Finds a valid solution by brute force. Waiting for caird to outgolf me by 50%.

Jelly, 19 bytes

RSr_\ṖṬŒ!ṁ8ドルRR¤UƑƇḢ

Try it online!

Finds a valid solution by brute force. Waiting for caird to outgolf me by 50%.

Jelly, 16 bytes

RØ.ṗŒpFS=9ƲƇUƑƇḢ

Try it online!

Finds a valid solution by brute force. Waiting for caird to outgolf me by 50%.

Source Link
hyperneutrino
  • 42.8k
  • 5
  • 72
  • 227
Loading

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