You are given a task:
Course participants CPython are interested in playing chess.
This game is played by two players. The winning participant gets 1 point, for a draw they get 0.5 points for both participants.
Once Rasulbek, Sarvar, Shoxzod and Sevinch held a tournament. The tournament consists of 3 rounds in which all participants play against each other.
Rasulbek is interested in writing game results and tournament results. But this time he forgot to write down the results of the games. He only had information about who scored how many points in the tournament. In order to fill his diary, he wanted to write any possible match results that correspond to the results of this tournament so that the match results are not empty.
Your task is to restore the results of the game, knowing who scored how many points in the tournament (a solution is guaranteed to exist, any solution can be printed).
Examples:
Input
3 2 1 0
Output
Rasulbek 1 - 0 Sarvar
Shoxzod 1 - 0 Sevinch
Sevinch 0 - 1 Rasulbek
Shoxzod 0 - 1 Sarvar
Rasulbek 1 - 0 Shoxzod
Sevinch 0 - 1 Sarvar
Input
1.5 1.5 1.5 1.5
Output
Shoxzod 0.5 - 0.5 Rasulbek
Sevinch 0.5 - 0.5 Sarvar
Rasulbek 0.5 - 0.5 Sarvar
Shoxzod 0.5 - 0.5 Sevinch
Sevinch 0.5 - 0.5 Rasulbek
Shoxzod 0.5 - 0.5 Sarvar
And the solution to this problem is given (Python):
u = [[0, 1], [2, 3], [0, 2], [1, 3], [0, 3], [1, 2]]
sh = {
0: "Rasulbek",
1: "Sarvar",
2: "Shoxzod",
3: "Sevinch"
}
def getInput():
return list(map(float, input().split()))
def solved(x):
for j in range(6):
s2 = x % 3
x //= 3
if s2 == 0:
a, b = 1, 0
elif s2 == 1:
a, b = 0, 1
else:
a, b = 0.5, 0.5
print(f"{sh[u[j][0]]} {a} - {b} {sh[u[j][1]]}")
if j % 2 == 1:
print()
need = getInput()
for i in range(666):
sc = [0] * 4
z = i
for j in range(6):
s2 = z % 3
z //= 3
if s2 == 0:
sc[u[j][0]] += 1
elif s2 == 1:
sc[u[j][1]] += 1
else:
sc[u[j][0]] += 0.5
sc[u[j][1]] += 0.5
if sc == need:
solved(i)
break
There is a bug in this solution. Please correct this bug and resubmit the solution.
The Levenshtein distance between your submitted solution and this solution must be no more than 1 character (not including spaces). This means you can delete, change or add a new symbol no more 1 time.