Compare commits

..

4 Commits

Author SHA1 Message Date
8a8cfa5c43 Prsteni 2023-07-18 22:13:48 +02:00
db736b30b3 Ptice 2023-07-18 21:51:43 +02:00
0d0ebece77 Quick Estimates 2023-07-18 21:41:12 +02:00
ef9eb28323 Racing Around the Alphabet 2023-07-18 21:38:10 +02:00
4 changed files with 68 additions and 0 deletions

22
prsteni.py Normal file
View File

@@ -0,0 +1,22 @@
import math
n = int(input())
radii = list(map(int, input().split()))
prev_r = None
prev_n = 1
prev_d = 1
for r in radii:
if prev_r is None:
prev_r = r
continue
n = prev_r * prev_n
d = r * prev_d
gcd = math.gcd(n, d)
n = n // gcd
d = d // gcd
print(f"{n}/{d}")
prev_n = n
prev_d = d
prev_r = r

23
ptice.py Normal file
View File

@@ -0,0 +1,23 @@
ADRIAN = "ABC" * 34
BRUNO = "BABC" * 25
GORAN = "CCAABB" * 17
n = int(input())
answers = input()
adrian_score = bruno_score = goran_score = 0
for i in range(n):
if answers[i] == ADRIAN[i]:
adrian_score += 1
if answers[i] == BRUNO[i]:
bruno_score += 1
if answers[i] == GORAN[i]:
goran_score += 1
max_score = max((adrian_score, bruno_score, goran_score))
print(max_score)
if adrian_score == max_score:
print("Adrian")
if bruno_score == max_score:
print("Bruno")
if goran_score == max_score:
print("Goran")

3
quickestimate.py Normal file
View File

@@ -0,0 +1,3 @@
n = int(input())
for _ in range(n):
print(len(input()))

20
racingalphabet.py Normal file
View File

@@ -0,0 +1,20 @@
import math
def calculate_distance(aphorism: str) -> int:
tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ '"
prev_s = aphorism[0]
total_distance = 0
for s in aphorism:
current_distance = (tokens.index(prev_s) - tokens.index(s)) % 28
if current_distance > 14:
current_distance = 28 - current_distance
prev_s = s
total_distance += current_distance
return 60 * math.pi / 28 * total_distance
n = int(input())
for _ in range(n):
aphorism = input()
print(calculate_distance(aphorism) / 15 + len(aphorism))