Here's a solution to "The House Robber Problem", in Python 3, using a Genetic Algorithm.

Find a good solution to the house robber problem, using a Genetic Algorithm.

The solution found is not necessarily optimal.

The problem:
A robber wishes to maximize the value of robbing houses on a given street full of houses. However, he/she cannot rob adjacent houses; if attempted, this will result in being caught.

Values of robbing each house, as floats, one per line - on stdin.


  1. The total value obtained by the robber.
  2. List of tuples. Each tuple is the value of one house, and "rob" or "skip".

On genetic algorithms: Wikipedia article

Hits: 2050
Timestamp: 2024-03-01 13:12:35 PST

Back to Dan's tech tidbits

You can e-mail the author with questions or comments: