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:

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

On genetic algorithms: Wikipedia article

Hits: 2300

Timestamp: 2024-09-11 18:45:40 PDT

Back to Dan's tech tidbits

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