diff options
| -rw-r--r-- | challenge-194/robert-dicicco/python/ch-2.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/challenge-194/robert-dicicco/python/ch-2.py b/challenge-194/robert-dicicco/python/ch-2.py new file mode 100644 index 0000000000..3b68b1e8a8 --- /dev/null +++ b/challenge-194/robert-dicicco/python/ch-2.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +''' + +AUTHOR: Robert DiCicco + +DATE: 2022-12-06 + +Challenge 194 Frequency Equalizer ( Python ) + + + +SAMPLE OUTPUT + +python .\FrequencyEqualizer.py + +Input: $s = abbc + +Output: 1 + + + +Input: $s = xyzyyxz + +Output: 1 + + + +Input: $s = xzxz + +Output: 0 + +''' + + + +ss = ["abbc", "xyzyyxz", "xzxz"] + +x = 0 + + + +for s in ss : + + x = 0 + + seen = dict() + + print(f"Input: $s = {s}") + + ln =len(s) + + while x < ln : + + zsub = s[x:x+1] + + if zsub in seen : + + seen[zsub] += 1 + + else : + + seen[zsub] = 1 + + x += 1 + + + + highest = max(seen.values()) + + lowest = min(seen.values()) + + + + if (lowest + 1 == highest) : + + print("Output: 1\n") + + else : + + print("Output: 0\n") |
