diff options
Diffstat (limited to 'challenge-194/robert-dicicco/python')
| -rw-r--r-- | challenge-194/robert-dicicco/python/ch-1.py | 97 | ||||
| -rw-r--r-- | challenge-194/robert-dicicco/python/ch-2.py | 81 |
2 files changed, 178 insertions, 0 deletions
diff --git a/challenge-194/robert-dicicco/python/ch-1.py b/challenge-194/robert-dicicco/python/ch-1.py new file mode 100644 index 0000000000..74bb343b88 --- /dev/null +++ b/challenge-194/robert-dicicco/python/ch-1.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python + +''' + +AUTHOR: Robert DiCicco + +DATE: 2022-12-05 + +Challenge 194 Digital Clock ( Python ) + +------------------------------------------- + +SAMPLE OUTPUT + +python .\DigitalClock.py + +Input: $time = '?5:00' + +Output: 1 + + + +Input: $time = '?3:00' + +Output: 2 + + + +Input: $time = '1?:00' + +Output: 9 + + + +Input: $time = '2?:00' + +Output: 3 + + + +Input: $time = '12:?5' + +Output: 5 + + + +Input: $time = '12:5?' + +Output: 9 + +''' + + + +templates = ["?5:00", "?3:00", "1?:00", "2?:00", "12:?5","12:5?"] + + + +def GetDigit(tp, n) : + + print(f"Input: $time = '{tp}'") + + print("Output: ", end = " ") + + if (( n == 0 ) and (tp[1] < '4')) : + + print("2\n") + + elif (( n == 0 ) and (tp[1] >= '4' )) : + + print("1\n") + + elif (( n == 1 ) and (tp[0] <= '1')) : + + print("9\n") + + elif (( n == 1 ) and (tp[0] == '2')) : + + print("3\n") + + elif ( n == 3) : + + print("5\n") + + elif ( n == 4) : + + print("9\n") + + else : + + print("Error!") + + + +for tp in templates : + + GetDigit(tp,tp.index('?')) 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") |
