Racing Around the Alphabet
This commit is contained in:
20
racingalphabet.py
Normal file
20
racingalphabet.py
Normal 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))
|
||||||
Reference in New Issue
Block a user