Refactor TRANSITION-POSITION to use iteration

Using iterative function makes the tests run in 83% of the time of the
old recursive function.
Merge pull request #18 from dlowe-net/refactor-transition-position

Refactor TRANSITION-POSITION to use iteration