Started with the trivial implementation of scanning all options. As JBM noted (above) It solved the puzzle if number of houses where under 20. 50 was a timeout
So introduced dynamic programming (memoization). Now all is solved, and I’m happy.
Then looked at the top solution - and saw a simple O(n) approach and had a big silly smile all over my face. This is one of the reasons I love CG so much