This is similar to the "longest increasing subsequence" problem. A very likely "solution" would be to:
- create a directed, acyclic graph, connecting numbers that are a distance of 10 or more - this is O(n2)
- iteratively, find the longest path start at the lowest number still contained in the graph
- each time a path is found, eliminate those numbers and edges from the graph
You could probably use one of the
Graph modules.