-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path063.py
More file actions
35 lines (26 loc) · 747 Bytes
/
063.py
File metadata and controls
35 lines (26 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# https://www.freecodecamp.org/learn/daily-coding-challenge/2025-10-12
def battle(our_team, opponent):
wins = [0, 0]
our_words = our_team.split()
their_words = opponent.split()
for i in range(len(our_words)):
us = get_score(our_words[i])
them = get_score(their_words[i])
if us > them:
wins[0] += 1
elif us < them:
wins[1] += 1
if wins[0] > wins[1]:
return "We win"
elif wins[0] < wins[1]:
return "We lose"
else:
return "Draw"
def get_score(word):
total_score = 0
for char in word:
score = ord(char.lower()) - 96
if char.isupper():
score *= 2
total_score += score
return total_score