diff --git a/2024/04/15-04-24/a.py b/2024/04/15-04-24/a.py new file mode 100644 index 0000000..ebe78db --- /dev/null +++ b/2024/04/15-04-24/a.py @@ -0,0 +1,12 @@ +def square_size(meteors, t) -> int: + posX = [m[0] + m[2]*t for m in meteors] + posY = [m[1] + m[3]*t for m in meteors] + win_size = ( + (max(posX)-min(posX)) * + (max(posY)-min(posY)) + ) + return win_size + + +N = int(input()) +meteors = [[int(i) for i in input().split()] for _ in range(N)] \ No newline at end of file diff --git a/2024/04/15-04-24/d.py b/2024/04/15-04-24/d.py new file mode 100644 index 0000000..c36c333 --- /dev/null +++ b/2024/04/15-04-24/d.py @@ -0,0 +1,17 @@ +from math import sqrt +N=int(input()) + +def premier(x): + for i in range(2,int(sqrt(x))+1): + if x%i==0: + return False + return True + +if premier(N): + print('N') +else: + k=sqrt(N) + if int(k)**2==N and premier(k): + print('N') + else: + print('Y') \ No newline at end of file diff --git a/2024/04/15-04-24/e.py b/2024/04/15-04-24/e.py new file mode 100644 index 0000000..a839a98 --- /dev/null +++ b/2024/04/15-04-24/e.py @@ -0,0 +1,46 @@ +N = int(input()) +customers = [int(i) for i in input().split()] + +results = [0 for _ in range(N+1)] +# contient num. cust suivi de: +# 0: jsp +# 1: forcément G +# 2: forcément S + +stack = [] # alt, vu +def depop(action): + seen = False + for i, (el, se) in enumerate(reversed(stack)): + if el == action: + del stack[len(stack)-i-1] + if se and seen: + raise ValueError + elif se: + return 1 # G + elif seen: + return 2 # S + return 1 # G + + stack[len(stack)-i-1] = (el, True) + seen = True + +def load_results(): + for action in customers: + #print(action, stack) + if action > 0: + stack.append((abs(action), False)) + else: + results[abs(action)] = depop(abs(action)) + +try: + load_results() + for i in results[1:]: + if i==0: + print("U", end="") # Unknown + elif i==1: + print("G", end="") + else: + print("S", end="") + print() +except ValueError: + print("*") \ No newline at end of file diff --git a/2024/04/15-04-24/i.py b/2024/04/15-04-24/i.py new file mode 100644 index 0000000..791982f --- /dev/null +++ b/2024/04/15-04-24/i.py @@ -0,0 +1,38 @@ +from typing import TypeVar + +Nb = TypeVar("Nb", int, float) + +def area(points: list[tuple[Nb, Nb]], count_border: bool=True) -> int: + def distance(p1: tuple[Nb, Nb], p2: tuple[Nb, Nb]) -> float: + return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1]) + + def get_info(x1: Nb, y1: Nb, x2: Nb, y2: Nb) -> Nb: + return x1*y2 - y1*x2 + + def inner_area() -> float: + first_x, first_y = points[0] + prev_x, prev_y = first_x, first_y + res = 0 + + for i in range(len(points)-1): + next_x, next_y = points[i+1] + res = res + get_info(prev_x, prev_y, next_x, next_y) + prev_x = next_x + prev_y = next_y + res = res + get_info(prev_x, prev_y, first_x, first_y) + return abs(res)/2.0 + + def border() -> float: + distances = [distance(points[i], points[i+1]) for i in range(len(points)-1)] + distances.append(distance(points[-1], points[0])) + return sum(distances) + + if count_border: + return int(inner_area()+border()//2 +1) + + return int(inner_area()) + +N, R = map(int, input().split()) +crops =[[int(i) for i in input().split()] for _ in range(N)] + +current_area = area(crops, count_border=False) diff --git a/2024/04/15-04-24/k.py b/2024/04/15-04-24/k.py new file mode 100644 index 0000000..ef830d4 --- /dev/null +++ b/2024/04/15-04-24/k.py @@ -0,0 +1,41 @@ +from functools import cache + +voyelles = ["A", "E", "I", "O", "U", "Y"] + +N = int(input()) +words = [input()[:3] for _ in range(N)] + + +@cache +def find_consonant(w_index=0, previous=0): + if w_index == len(words): + return 0 + + word = words[w_index] + + valid = [] + + count = previous + for i, w in enumerate(word): + if w not in voyelles: + count += 1 + else: + count = 0 + + # print(i, word[:i+1], count) + + if count != 3: + val = find_consonant(w_index=w_index+1, previous=count) + if val == "*": + continue + valid.append(val+i+1) + else: + break + + if valid == []: + return "*" + return min(valid) + + + +print(find_consonant()) \ No newline at end of file