Rewritten program using numpy -> speedup around 60x