diff --git a/problems/P12781.py b/problems/P12781.py new file mode 100644 index 0000000..4b8ad0c --- /dev/null +++ b/problems/P12781.py @@ -0,0 +1,37 @@ +def ccw(first: list, second: list, third: list): + cross_porduct = (second[0] - first[0])*(third[1] - first[1]) - \ + (third[0] - first[0])*(second[1] - first[1]) + if cross_porduct > 0: + return 1 + if cross_porduct < 0: + return -1 + return 0 + + +def comparator(left: list, right: list): + if left[0] == right[0]: + return left[1] <= right[1] + return left[0] <= right[1] + + +def solution(first: list, second: list): + first_scope = ccw(*first, second[0]) * ccw(*first, second[1]) + second_scope = ccw(*second, first[0]) * ccw(*second, first[1]) + + if first_scope == 0 and second_scope == 0: + return False + + return first_scope <= 0 and second_scope <= 0 + + +def test_solution(): + assert solution([[0, 0], [6, 2]], [[5, -4], [2, 2]]) == True + assert solution([[-1, -5], [6, 3]], [[1, 10], [-4, -1]]) == False + + +if __name__ == "__main__": + lines = list(map(int, input().split())) + if solution([lines[:2], lines[2:4]], [lines[4:6], lines[6:]]): + print(1) + else: + print(0) diff --git a/problems/P17174.py b/problems/P17174.py new file mode 100644 index 0000000..88f98b5 --- /dev/null +++ b/problems/P17174.py @@ -0,0 +1,16 @@ +def solution(amount: int, groupTO: int): + count = amount + + while amount > 0: + amount //= groupTO + count += amount + return count + + +def test_solution(): + assert solution(13, 10) == 14 + assert solution(100, 8) == 113 + + +if __name__ == "__main__": + print(solution(*map(int, input().split())))