Evolution in Parallel
First figure out how to determine whether one string can evolve into another. This is a caterpillar walk across both strings. If the letters at the indices at the two strings don't match, increment the pointer in the longer string until they do. If you get to the last letter of both and they match, you have an edge in your graph!
Naive solution:
- Build whole graph using method above
- run topological sort from the current species
- only a single node may enqueue two nodes during the sort
You may think this fails....consider * / \ * * |\ /| | X | |/ \| * *