Transform those strings
Given below is a set of rules that can be used to transform one string into another:
- ‘t’ → ‘i’
- {‘a’ – ‘z’} → ‘m’
- ‘s’ → ‘i’
- ‘a’ → ‘aa’
- {‘a’–‘z’}→‘’
- ‘t’ → ‘r’
- {‘a’ – ‘g’} → ‘h’
- ‘o’ → ‘a’
- ‘t’ → ‘s’
- {‘t’ – ‘z’} → ‘u’
// change ‘t’ to ‘i’
// change ‘a’, or ‘b’, or ‘c’, ..., or ‘z’ to ‘m’
//delete‘a’,or‘b’,or‘c’,... ,or‘z’
Sets are always given as a range, i.e. {‘a’ – ‘c’} is the set with the characters {‘a’,‘b’,‘c’}
Write a program that reads two strings, and prints the steps required to transform the first string
into the second.
Input
The input file contains several test cases with a blank line between two consecutive.
Output
For each test case, print the steps required to transform the first string into the second. The steps in the transformation must be printed in the form:
rule: origString -> newString
Note that several transformations may exist, your program only needs to find one. It is also possible that the first string cannot be transformed into the second. In this case, your program should simply output the word ‘no’
It must be a blank line between two consecutive outputs.
Sample input
thinner rih
a x
Sample output
6: thinner -> rhinner
5: rhinner -> rinner
7: rinner -> rinnhr
5: rinnhr -> rinhr
5: rinhr -> rihr
2/2
5: rihr -> rih
no