diff options
Diffstat (limited to 'challenge-255/zapwai/python/ch-1.py')
| -rw-r--r-- | challenge-255/zapwai/python/ch-1.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-255/zapwai/python/ch-1.py b/challenge-255/zapwai/python/ch-1.py new file mode 100644 index 0000000000..1ad73f503f --- /dev/null +++ b/challenge-255/zapwai/python/ch-1.py @@ -0,0 +1,25 @@ +def proc(s, t): + print("Input: s =",s,"t =",t); + freqs = {}; + freqt = {}; + for c in s: + freqs[c] = 0; + for c in s: + freqs[c] += 1; + for c in t: + freqt[c] = 0; + for c in t: + freqt[c] += 1; + for i in range(len(s)): + if freqs[s[i]] < freqt[s[i]]: + ans = s[i]; + break; + else: + for k in freqt.keys(): + if not k in freqs.keys(): + ans = k; + break; + print("Output:",ans); +proc("Perl", "Preel"); +proc("Weekly", "Weeakly"); +proc("Box", "Boxy"); |
