Evolution in Parallel: Difference between revisions

From programming_contest
Jump to navigation Jump to search
imported>Kmk21
Created page with "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..."
 
imported>Kmk21
No edit summary
Line 7: Line 7:


You may think this fails....consider
You may think this fails....consider
<nowiki>
<nowiki>
   *
   *
   / \
   / \

Revision as of 21:50, 24 August 2016

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 |
 |/ \|
 *   *