diff options
Diffstat (limited to 'challenge-276/sgreen/python/ch-1.py')
| -rwxr-xr-x | challenge-276/sgreen/python/ch-1.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-276/sgreen/python/ch-1.py b/challenge-276/sgreen/python/ch-1.py new file mode 100755 index 0000000000..589990a0ba --- /dev/null +++ b/challenge-276/sgreen/python/ch-1.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import sys + + +def complete_day(hours: list) -> int: + """ + Counts the number of pairs of hours in the given list that sum up to a multiple of 24. + + Args: + hours (list): A list of integers representing the hours. + + Returns: + int: The number of pairs of hours that sum up to a multiple of 24. + """ + count = 0 + items = len(hours) + + for i in range(items-1): + for j in range(i+1, items): + if (hours[i] + hours[j]) % 24 == 0: + count += 1 + + return count + + +def main(): + # Convert input into integers + array = [int(n) for n in sys.argv[1:]] + result = complete_day(array) + print(result) + + +if __name__ == '__main__': + main() |
