--- from: http://rosettacode.org/wiki/Kernighans_large_earthquake_problem