[Community Puzzle] Tennis score

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @VilBoub,validated by @rc95401,@Kellthazar and @LantarSidonis.
If you have any issues, feel free to ping them.

In the last test case, when Bequ consecutively scores two times:

I.Begu scores 1 point
I.Beguā€¦ 4 6 6 | 6
J.Paoliniā€¦ 6 1 6 | 5

I.Begu scores 1 point
I.Beguā€¦ 4 6 7 | 0
J.Paoliniā€¦ 6 1 6 | 0

When the points change from 6:5 to 7:5, why it did not define Bequ winning one more game like the above?

In the tie-break rules: ā€œā€¦ unless it is the last game ā€¦, in this case there it takes at least 10 points to win the game.ā€
Actually, here ā€˜last gameā€™ was meant to be ā€˜last setā€™.

2 Likes

I seeā€¦the rules are more complicated than expected.
In the ā€œTie Breakā€ test case, I got steps as below. It looks like I was out-tracked somewhere. Could you spot the problem?

A.Sasnovich scores 1 point
M.Trevisan..... 6 | 3
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 6 | 4
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 6 | 5
A.Sasnovich.... 6 | 4
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 5
A.Sasnovich.... 6 | 5
M.Trevisan scores 1 point
M.Trevisan..... 6 | 6
A.Sasnovich.... 6 | 5
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 6
A.Sasnovich.... 6 | 6
M.Trevisan scores 1 point
M.Trevisan..... 6 | 7
A.Sasnovich.... 6 | 6
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 7
A.Sasnovich.... 6 | 7
M.Trevisan scores 1 point
M.Trevisan..... 6 | 8
A.Sasnovich.... 6 | 7
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 8
A.Sasnovich.... 6 | 8
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 8
A.Sasnovich.... 6 | 9
M.Trevisan scores 1 point
M.Trevisan..... 6 | 9
A.Sasnovich.... 6 | 9
M.Trevisan scores 1 point
M.Trevisan..... 6 | 10
A.Sasnovich.... 6 | 9
A.Sasnovich scores 1 point
M.Trevisan..... 6 | 10
A.Sasnovich.... 6 | 10
M.Trevisan scores 1 point
M.Trevisan..... 6 | 11
A.Sasnovich.... 6 | 10
M.Trevisan scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 0
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 1
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 2
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 3
M.Trevisan scores 1 point
M.Trevisan..... 7 | 1
A.Sasnovich.... 6 | 3
M.Trevisan scores 1 point
M.Trevisan..... 7 | 2
A.Sasnovich.... 6 | 3
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 2
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 7 | 3
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 7 | 4
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 7 | 5
A.Sasnovich.... 6 | 4
M.Trevisan scores 1 point
M.Trevisan..... 7 | 6
A.Sasnovich.... 6 | 4
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 6
A.Sasnovich.... 6 | 5
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 6
A.Sasnovich.... 6 | 6
M.Trevisan scores 1 point
M.Trevisan..... 7 | 7
A.Sasnovich.... 6 | 6

Thanks

M.Trevisan..... 6 | 11
A.Sasnovich.... 6 | 10
M.Trevisan scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 0
A.Sasnovich scores 1 point
M.Trevisan..... 7 | 0
A.Sasnovich.... 6 | 1

Here, after Trevisan wins the tie-break with 12:10 and thus wins the whole set with 7:6, a new set begins, so the next game should count the points again as 0,15,30,40,AD, etc

Indeed, tennis scoring is not very logical. They play for hours, but the match might be decided on a very few important points, and the winner might have scored much less total points than the loserā€¦ But maybe that makes it more exciting. A player might come back and win the match even from 0:6 0:6 0:5

PS: my suggestion for puzzle creators as the next ā€˜game scoringā€™ puzzle: chess swiss tournament with Buchholz or Sonnebornā€“Berger tie-break rulesā€¦ :slight_smile:

1 Like

I.Begu vs J.Paolini : Infosys Match Centre - Roland-Garros - Le site officiel du Tournoi de Roland-Garros 2023

M.Trevisan vs A.Sasnovich : Infosys Match Centre - Roland-Garros - Le site officiel du Tournoi de Roland-Garros 2023

if I didnā€™t make any mistakes when transcribing the pointsā€¦

I passed all the test cases and all the validators except the second, and I donā€™t know what the problem can be. Any suggestions to find where the error is?

1 Like

Validator 2 is similar to test 2, and the differences are in the third line of input. Maybe you can create some custom cases by changing that line to test your code?

I passed all the test cases but after submitting, the last test ā€œMatch pointā€ failed. I have no idea why as I cannot see any input.
Any ideas?

I also encounter an issue with the last validator. I am not sure that the validators are implemented correctlyā€¦this is pretty frustrating. All other tests pass

*** Tie-break rules:**
when we arrive at the score 6 6 in a set, then a ā€œtie-breakā€ is played. it no longer takes 4 points but 7 points to win the game (always with a difference of at least two points, the score in the tie-break is unlimited !) unless it is the last game (the 3rd for women, the 5th for men), in this case there it takes at least 10 points to win the game.
The winner of the game then wins the set on the score 7 6.

I implemented that case too (the last test ā€œItā€™s not finishā€ is green) but still the ā€œMatch pointā€ validator test fails

Itā€™s the match point of the game in the previous link : .V.Azarenka vs J.Teichmann

I am stucked in the validator ā€œLong Gameā€ even if all the tests passed correctly. Is it possible to give tips ?

@VilBoub Is it possible to give the match related to the ā€œLong Gameā€ validator ?

the validator ā€œLong Gameā€ : J.Isner vs Q.Halys (Rolland Garros 2022_05_22)

Thank you!

My mistake was related to this rule

the score in the tie-break is unlimited !) unless it is the last game (the 3rd for women, the 5th for men), in this case there it takes at least 10 points to win the game.

It is at least 10 points for the last set, not for the last match winning set.
Hard to debug but finally succeded!

Iā€™m trying to code this in C# and wondering how to convert the hexadecimal (ā€œ1Aā€) to the string ā€œ0001 1010ā€. Any help is appreciated.
Peter

    static string HexToBinary(string hex)
    {
        hex = hex.Replace(" ", "");
        string binary = "";
        foreach (char c in hex)
        {
            int value = Convert.ToInt32(c.ToString(), 16);
            binary += Convert.ToString(value, 2).PadLeft(4, '0');
        }
        return binary;
    }

I ran into the problem of passing all except Validator 2 as well, and by checking the contribution found out the following:

  • case 2 is clearly over the number of points that give [0,15,30,40] (players 0 and 1 have 5 and 6 points, respectively)
  • for validator 2, one of the players is still in the [0,15,30,40] points range (4 points), while the other is over (5 points).

Probably @Nostale, a long time ago, encounter the same problem: seeing 40 as valid score, but it should be ā€˜-ā€™ since the other player is over the edge of valid game scores (i.e. outputting 40/AV while it should be -/AV).
Apologies, I donā€™t know the tennis lingo so quite possibly I am explaining it wrong.

So, a small imbalance in test vs validator (validator is testing an edge case not covered in the cases) - but still I liked this puzzle a lot.