Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

mirai avatar mirai 0 Точки

3.Football Cards Python Fundamentals

Здравейте!
Може ли една корекция на кода? Judge ми дава 80/100

Most football fans love it for the goals and excitement. Well, this problem doesn't. You are to handle the referee's little notebook and count the players who were sent off for fouls and misbehavior.

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.

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.

Output

Print the remaining players as described above and add another line (as shown above) if the game was terminated.

Example

Input

Output

A-1 A-5 A-10 B-2

Team A - 8; Team B - 10

A-1 A-5 A-10 B-2 A-10 A-7 A-3

Team A - 6; Team B - 10

Game was terminated



list_cards = input().split()
#The task: Given a list of cards (could be empty) !!?
playersA = 11
playersB = 11

list_of_all_cards = []

for i in list_cards:
    if i not in list_of_all_cards:
        list_of_all_cards.append(i)

for card_index in range(len(list_of_all_cards)):
    list_of_current_card = list_of_all_cards[card_index].split("-")
    if list_of_current_card[0] == "A":
        playersA -= 1
    elif list_of_current_card[0] == 'B':
        playersB -= 1

print(f"Team A - {playersA}; Team B - {playersB}")
if playersA < 7 or playersB < 7:
    print('Game was terminated')
Тагове:
0
Programming Fundamentals
Vitala avatar Vitala 3 Точки

Ако все още ти трябва или пък на някой друг... 

cards = input().split()

player_number = []
[player_number.append(x) for x in cards if x not in player_number]

team_a = 11
team_b = 11

for index in range(len(player_number)):
    if "A-" in player_number[index]:
        team_a -= 1
        if team_a < 7:
            break
    elif "B-" in player_number[index]:
        team_b -= 1
        if team_b < 7:
            break

print(f"Team A - {team_a}; Team B - {team_b}")

if team_a < 7 or team_b < 7:
    print("Game was terminated")
1
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.