diff options
| author | Zapwai <zapwai@gmail.com> | 2024-02-08 14:13:49 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-08 14:13:49 -0500 |
| commit | 5d082eda650b759fc16ee940f366af9a2f48832a (patch) | |
| tree | 840ca2942a255b83bde41bf2ef61ce63285b92d9 | |
| parent | 7e45d7c7dcbc8ca7abfa65a55d124e216729cb80 (diff) | |
| download | perlweeklychallenge-club-5d082eda650b759fc16ee940f366af9a2f48832a.tar.gz perlweeklychallenge-club-5d082eda650b759fc16ee940f366af9a2f48832a.tar.bz2 perlweeklychallenge-club-5d082eda650b759fc16ee940f366af9a2f48832a.zip | |
cleaner version
| -rw-r--r-- | challenge-255/zapwai/python/ch-1.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/challenge-255/zapwai/python/ch-1.py b/challenge-255/zapwai/python/ch-1.py index 1ad73f503f..96dd77debf 100644 --- a/challenge-255/zapwai/python/ch-1.py +++ b/challenge-255/zapwai/python/ch-1.py @@ -10,15 +10,16 @@ def proc(s, 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]; + ans = None; + for k in freqt.keys(): + if not k in freqs.keys(): + ans = k; break; - else: - 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"); |
