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.

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

Output:

  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: 2444
Timestamp: 2024-12-27 08:04:21 PST

Back to Dan's tech tidbits

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