|Let f be a function that takes a string composed of a's, b's, and c's, and replaces every occurrence of 'a' with arep, 'b' with brep, and 'c' with crep. Your code will compute the length of (quotes for clarity): |
f( f( f( ... f(a) ... ) ) ) : f applied iter times to the string "a"
Since the lengths can grow very large with only a few iterations, you will return the length mod m.
For example, if
arep = abc
brep = c
crep = ba
iter = 3
m = 7
then you will find the length of
f(f(f(a))) = f(f(abc)) = f(abccba) = abccbabacabc ,
which is 12. Then you will compute 12 mod 7 = 5, and return 5.