3. Football Cards
Здравейте , имам проблем с тази задача ,
The rules: Two teams, named "A" and "B" have 11 players each. The players on each team are numbered from 1 to 11. Any player may be sent off the field by being given a red card. If one of the teams has less than 7 players remaining, the game is stopped immediately by the referee, and the team with less than 7 players loses.
A card is a string with the team's letter ('A' or 'B') followed by a single dash and player's number. e.g. the card 'B-7' means player #7 from team B received a card. (index 6 of the list)
The task: Given a list of cards (could be empty), return the number of remaining players on each team at the end of the game in the format: "Team A - {players_count}; Team B - {players_count}". If the game was terminated print an additional line: "Game was terminated"
Note for the random tests: If a player that has already been sent off receives another card - ignore it.
Input
The input (the cards) will come on a single line separated by a single space.
Работи вярно и тестовете си минават но ми дава 80/100 в judge
Мерси много :)))
Дава 100/100 , но при подаване на вход от сорта на : " А-1 А-2 А-3 А-4 А-5 А-6 А-7 А-8 "
намаля играчите до под 7 и никога не спира. В случая ползваш ако са < 7 само да принтиращ но не спираш играта , явно и джъдж не го оценява както трябва .
Така също ще даде 80/100. Трябва да прекъснете цикъла с условието за броя на играчите.
Ето и трети вариант на задачата:
string_players=input().split(" ")
list_one=[]
for i in string_players:
list_one.append(i)
team_one=11
team_two=11
terminated=False
new_list=list(set(list_one))
for i in range(1,11+1):
team_one-=int(new_list.count(f"A-{i}"))
team_two-=int(new_list.count(f"B-{i}"))
if team_one <7 or team_two<7:
print(f"Team A - {team_one}; Team B - {team_two}")
print("Game was terminated")
terminated=True
break
if terminated!=True:
print(f"Team A - {team_one}; Team B - {team_two}")