Algorithm works for all but 4 and 6 moves