import re
#thanks to http://stackoverflow.com/questions/937697/can-you-pass-a-dictionary-when-replacing-strings-in-python
def dict_sub(d, text):
""" Replace in 'text' non-overlapping occurences of REs whose patterns are keys
in dictionary 'd' by corresponding values (which must be constant strings: may
have named backreferences but not numeric ones). The keys must not contain
anonymous matching-groups.
Returns the new string."""
# Create a regular expression from the dictionary keys
regex = re.compile("|".join("(%s)" % k for k in d))
# Facilitate lookup from group number to value
lookup = dict((i+1, v) for i, v in enumerate(d.itervalues()))
# For each match, find which group matched and expand its value
return regex.sub(lambda mo: mo.expand(lookup[mo.lastindex]), text)
def replace(string):
d={'A': 'is', 'B': 'mm', 'C': 'oo', 'D': 'rgr', 'E':'ryg', 'F': 'dth', 'G': 'you', 'H': 'esol', 'I': 'ionA', 'J':'GDaBarA', 'K':'veECFHutI','L':'PQ', 'M':'n','N':'m', 'O':'oaNcho', 'P':'MO', 'Q':'NR', 'R':'sky','S':'JKL'}
return dict_sub(d, string)
string = 'S'
for i in xrange(0,20):
print("%i: %s" %(i, string))
string = replace(string)
Public Class Challenge
Private msg As String = ""
Public Sub Start()
S()
Debug.Print(msg)
End Sub
Public Sub AddLetters(letters As String)
msg &= letters
End Sub
Public Sub A()
AddLetters("is")
End Sub
Public Sub B()
AddLetters("mm")
End Sub
Public Sub C()
AddLetters("oo")
End Sub
Public Sub D()
AddLetters("rgr")
End Sub
Public Sub E()
AddLetters("ryg")
End Sub
Public Sub F()
AddLetters("dth")
End Sub
Public Sub G()
AddLetters("you")
End Sub
Public Sub H()
AddLetters("esol")
End Sub
Public Sub I()
AddLetters("ion")
A()
End Sub
Public Sub J()
G()
D()
AddLetters("a")
B()
AddLetters("ar")
A()
End Sub
Public Sub K()
AddLetters("ve")
E()
C()
F()
H()
AddLetters("ut")
I()
End Sub
Public Sub L()
P()
Q()
End Sub
Public Sub M()
AddLetters("n")
End Sub
Public Sub N()
AddLetters("m")
End Sub
Public Sub O()
AddLetters("oa")
N()
AddLetters("cho")
End Sub
Public Sub P()
M()
O()
End Sub
Public Sub Q()
N()
R()
End Sub
Public Sub R()
AddLetters("sky")
End Sub
Public Sub S()
J()
K()
L()
End Sub
End Class