Hearts is a 4-player game that uses the following scoring rules:
- Everyone starts with score 0.
- Each round every player gets a non-negative amount of points. The sum of the points is 26, and at least one player gets 13 or more points.1
- The points are then added to the players' score except if a player gets 26 points. If that happens, everyone else adds 26 to their score, and the player who got 26 points adds none.
- The game ends when someone gets a score of 100 or more. Until then, steps 2 and 3 are repeated.
Your task is to take 4 non-negative integers representing the scores of the players at the end of the game and decide if it's a valid game. That is, are those scores possible to achieve by following the rules until the game ends.
Samples
[26,26,26,26] -> False (The game has not ended since no one has a score of 100 or more)
[1,1,2,100] -> True ([1,0,0,25]+[0,1,0,25]+[0,0,1,25]+[0,0,1,25])
[1,1,2,108] -> False (Sum not divisible by 26)
[26,26,26,260] -> False (Game should have ended before a score of 260 is reached. In fact, 125 is the maximum score a player can have)
[104,104,104,0]-> True ([26,26,26,0]+[26,26,26,0]+[26,26,26,0]+[26,26,26,0])
[0,0,0,104] -> False (One can't just add 26 points to his score. That would add 26 to the 3 other players)
[13,13,104,104]-> True ([0,0,13,13]+[0,0,13,13]+[0,0,13,13]+[0,0,13,13]+[0,0,13,13]+[0,0,13,13]+[13,0,13,0]+[0,13,0,13]+[0,0,13,13])
[10,10,120,120]-> False (The last turn must be [26,26,26,0] for two players to reach 120, but two players also have <26 score)
[0,0,5,125] -> False (The last turn can't be [0,0,0,26], suggested by Neil
[117,117,117,117]-> False (Last turn get >26 point and is not a [0,26,26,26])
[104,104,104,104]-> False (Even if last round is [13,5,4,4], it was [91,99,100,100] which is impossible)
[101,101,101,113]-> True ([7,7,6,6]+[26,26,26,0]+[26,26,0,26]+[26,0,26,26]+[0,26,26,26]+[13,13,0,0]+[0,0,13,13]+[3,3,4,16] thank AnttiP for the example)
[15,125,125,125] -> True ([5,13,4,4]+[5,4,13,4]+[5,4,4,13]+[0,26,26,26]+[0,26,26,26]+[0,26,26,26]+[0,26,26,26] as Nitrodon suggest)
This is code-golf so the shortest code in each language wins.
Note
- All true cases can be seen here. You can also see here for possibilities of score for a given amount of rounds and state(ended/not)
1 non-negative amount of points
is the game part. 13 is the Queen of spades
[15, 125, 125, 125]
. \$\endgroup\$[0, 0, 5, 125]
, which my previous answer revision mistakenly identified as possible. \$\endgroup\$