This looks to me like a Breadth First Search problem...
It is really similar to a problem on Top Coder I tried to solve a few weeks ago: https://github.com/davideanastasia/coding-exercises/blob/master/SmartWorldToy/SmartWorldToy.cpp In that case, the sequence was with letters, not numbers, but the solution should be really similar.
This looks to me like a Breadth First Search problem...
ReplyDeleteIt is really similar to a problem on Top Coder I tried to solve a few weeks ago: https://github.com/davideanastasia/coding-exercises/blob/master/SmartWorldToy/SmartWorldToy.cpp
In that case, the sequence was with letters, not numbers, but the solution should be really similar.