CodechefJul 02, 2025

Best of Two

Hazrat Ali

Codechef

Alice and Bob are playing a game. Each player rolls a standard six-sided die three times. The score of a player is calculated as the sum of the two highest rolls. The player with the higher score wins. If both players have the same score, the game ends in a tie.

Determine the winner of the game or if it is a tie.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case contains six space-separated integers A1A2A3B1B2 and B3 — the values Alice gets in her 3 dice rolls, followed by the values which Bob gets in his 3 dice rolls.

Output Format

For each test case, output on a new line Alice if Alice wins, Bob if Bob wins and Tie in case of a tie.

Note that you may print each character in uppercase or lowercase. For example, the strings tieTIETie, and tIe are considered identical.

Constraints

  • 1≤T≤10
  • 1≤A1,A2,A3,B1,B2,B3≤6

Sample 1:

Input
3
3 2 5 6 1 1
4 4 5 6 4 1
6 6 6 6 6 1

Output
Alice
Bob
Tie

Solution
T = int(input())

for _ in range(T):
    rolls = list(map(int, input().split()))
    alice = sorted(rolls[:3], reverse=True)
    bob = sorted(rolls[3:], reverse=True)

    alice_score = alice[0] + alice[1]
    bob_score = bob[0] + bob[1]

    if alice_score > bob_score:
        print("Alice")
    elif bob_score > alice_score:
        print("Bob")
    else:
        print("Tie")


 

Comments