Compare commits

..

5 Commits

Author SHA1 Message Date
c5728fa19e Heir's Dilemma 2023-07-25 15:54:01 +02:00
61b575d34f 1-D Frogger (Easy) 2023-07-25 12:40:12 +02:00
30941abe2d Help a PhD candidate out! 2023-07-25 10:09:41 +02:00
3963a3498a Herman 2023-07-25 10:05:59 +02:00
adb3cc79d4 Hitting the Targets 2023-07-25 09:52:50 +02:00
5 changed files with 101 additions and 0 deletions

30
1dfroggereasy.py Normal file
View File

@@ -0,0 +1,30 @@
n, s, m = map(int, input().split())
s -= 1
board = list(map(int, input().split()))
shadow_board = [0] * n
def print_ending(ending, hops):
print(ending)
print(hops)
exit()
hops = 0
while True:
if shadow_board[s] == 1:
print_ending("cycle", hops)
shadow_board[s] = 1
if board[s] == m:
print_ending("magic", hops)
if s + board[s] < 0:
print_ending("left", hops + 1)
if n <= s + board[s]:
print_ending("right", hops + 1)
s += board[s]
hops += 1

28
heirsdilemma.py Normal file
View File

@@ -0,0 +1,28 @@
def div_by_all(nr: int) -> bool:
digits = nr
for i in range(1, 7):
digit = digits % (10**i)
if nr % (digit // (10 ** (i - 1))) != 0:
return False
digits -= digit
return True
low, high = map(int, input().split())
if low % 2 == 1:
low += 1
total = 0
for i in range(low, high + 1, 2):
u = set(str(i))
if len(u) != len(str(i)):
continue
if "0" in u:
continue
if div_by_all(i):
total += 1
print(total)

6
helpaphd.py Normal file
View File

@@ -0,0 +1,6 @@
for _ in range(int(input())):
testcase = input()
if testcase == "P=NP":
print("skipped")
else:
print(sum(map(int, testcase.split("+"))))

5
herman.py Normal file
View File

@@ -0,0 +1,5 @@
import math
r = int(input())
print(r**2 * math.pi)
print(r**2 * 2)

32
hittingtargets.py Normal file
View File

@@ -0,0 +1,32 @@
def isInsideCircle(cx, cy, r, x, y):
dist = (x - cx) ** 2 + (y - cy) ** 2
return dist <= r**2
def isInsideRectangle(rx1, ry1, rx2, ry2, x, y):
return (rx1 <= x <= rx2) and (ry1 <= y <= ry2)
targets = []
for _ in range(int(input())):
t = input().split()
if t[0] == "rectangle":
targets.append(["R", int(t[1]), int(t[2]), int(t[3]), int(t[4])])
else:
targets.append(["C", int(t[1]), int(t[2]), int(t[3])])
for _ in range(int(input())):
x, y = map(int, input().split())
hits = 0
for target in targets:
if target[0] == "R":
hits += (
1
if isInsideRectangle(target[1], target[2], target[3], target[4], x, y)
else 0
)
else:
hits += 1 if isInsideCircle(target[1], target[2], target[3], x, y) else 0
print(hits)