Evolution in Parallel

From programming_contest
Revision as of 21:50, 24 August 2016 by imported>Kmk21
Jump to navigation Jump to search

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:

  1. Build whole graph using method above
  2. 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 |
 |/ \|
 *   *