aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/zapwai/python/ch-1.py
blob: 96dd77debf9a25dbf547a609232369dabde98191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
    ans = None;
    for k in freqt.keys():
        if not k in freqs.keys():
            ans = k;
            break;
    if ans is None:
        for i in range(len(s)):
    	    if freqs[s[i]] < freqt[s[i]]:
                ans = s[i];
                break;
    print("Output:",ans);
proc("Perl", "Preel");
proc("Weekly", "Weeakly");
proc("Box", "Boxy");