almost done, but brute force is too slow...
maybe could change to map reduce..on hadoop?