diff --git a/lab0/lab.py b/lab0/lab.py index ca8710f..96c522d 100644 --- a/lab0/lab.py +++ b/lab0/lab.py @@ -2,18 +2,34 @@ def middle(a, b, c): """Return the number among a, b, and c that is not the smallest or largest. Assume a, b, and c are all different numbers. """ - return ____ + return sorted([a, b, c])[1] def sum_digits(y: int) -> int: """ Sum all the digits of y. """ - pass + sum = 0 + while y > 0: + digit = y % 10 + y //= 10 + sum += digit + return sum def double_eights(n: int) -> bool: """ Return True if n has two eights in a row. """ - pass \ No newline at end of file + prev_eight = False + while n > 0: + digit = n % 10 + if digit == 8: + if prev_eight: + return True + else: + prev_eight = True + else: + prev_eight = False + n //= 10 + return False \ No newline at end of file