好的,我需要做的如下:
我创建了一个游戏大厅,有8位玩家加入,他们的获胜情况如下
Player1 = 10 wins
Player2 = 150 wins
Player3 = 100 wins
Player4 = 23 wins
Player5 = 76 wins
Player6 = 92 wins
Player7 = 1088 wins
Player8 = 0 wins
现在我们已经有了球员和他们的胜利,因此需要将球队分成两组,这样球队才是公平的,例如,对于拥有以下条件的球员来说,这是不公平的:
0,10,23,76获胜
VS
92、150、100和1088获胜。
我已经四处张望,找不到任何可以做到这一点的指南。
答案 0 :(得分:-1)
假设我们有每个玩家,并且在这样的字典中得分
@FindBy(xpath="//div[@id='applyleave_leaveBalance']")
private WebElement balance;
public void printBalance()
{
System.out.println(balance.getText());
}
您可以通过遍历每个球员得分并将其排序来将球员分为players = {player1:0, player2:15, ...}
和team1
两类
team2
如果您只是想对“一个然后另一个”进行排序,则可能会使用类似的
team1 = {}
team2 = {}
for player, score in players.items():
# Do something there to split over the two groups
# This will depend on what you consider "fair"
# In the end, you should be able to get your game set up. Good luck!
pass