Solved #31
Solved #120
Solved #20.  Surprisingly, the brute force solution turned out to be good enough.