Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: compute paths in Pascal's triangle (aka Tartaglia's one)by roboticus (Chancellor) |
on Mar 22, 2018 at 17:16 UTC ( [id://1211553]=note: print w/replies, xml ) | Need Help?? |
Looks like there are already a bunch of good solutions to your problem. But I did it anyway for a bit of diversion, so rather than throwing it away, I'll add it to the list:
Update: Rather than building the paths from the root to the specified node, I took advantage of the fact that there are only 1 or 2 moves upwards from any node. Then I recursively gathered the paths upwards. I then reversed the path before printing so it looks like a path from the root to the node, instead of the node to the root. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|