Hacker News new | ask | show | jobs
by abetusk 3 hours ago
I appreciate where the author is coming from, as we often have much more context because of training that have since atrophied a bit, but in defense of the dynamic programming solution, this generalizes very well.

As stated, the choose(2n,n) solution of course works but as soon as you deviate from a square, things can get more complicated. What if it's a rectangle? An arbitrary shape? One with holes? The dynamic programming solution takes all of this in stride (assuming, of course, that the conditions of only going right and down still hold).

Pascal's triangle is, after all, a dynamic programming solution. It just so happens that there's a "closed form" solution to their entries.

I'm all for clever tricks but I also appreciate much more a solution that generalizes well and gives more insight into a class of problems.