Divide a rectangle into a number of unequal triangles: Difference between revisions
Divide a rectangle into a number of unequal triangles (view source)
Revision as of 16:33, 26 January 2022
, 2 years ago→{{header|Raku}}: after all the blunders, init 6
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: use another 3) |
(→{{header|Raku}}: after all the blunders, init 6) |
||
Line 462:
=={{header|Raku}}==
<lang perl6># 20220123 Raku programming solution
# Proof :
#
# H---A-----B-------C---------D-----------E
# | |
# | |
# | |
# O---------------------------------------L
#
# ▲OEL is unique as its area is the sum of the rest.
#
# The sum of length on sides for ▲OED > ▲ODC > ... > ▲OAH
# so no pairs of any will meet the SSS congruence requirement.
sub UnequalDivider (\L,\H,\N where N > 2) {
my \part = $ = 0;
( [ (0,0), (L,H), (L,0) ], ).Array.append: gather @sequence.map: -> \chunk {
take [ (0,0), (L*part/sum,H), (L*(part+=chunk)/sum,H) ]
} ▼
▲ }
}
.say for UnequalDivider(1000,500,
{{out}}
<pre>
[(
[(
[(
</pre>
|