Markov algorithm solution

A solution to http://rosettacode.org/wiki/Execute_a_Markov_algorithm this is getting to the level of a (very) simple parser so there's lots of string handling in this one.