diff --git a/racingalphabet.py b/racingalphabet.py new file mode 100644 index 0000000..bf46a28 --- /dev/null +++ b/racingalphabet.py @@ -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))