[Community Puzzle] Score a Bridge deal

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Lanfeust,validated by @Timinator,@_SG_Sebastien and @_SG_Jarjar.
If you have any issues, feel free to ping them.

I don’t know Bridge, can someone explain how do we know if a contract was won or lost ? I’m unable to find this in the statement.

You win the contract if the number of tricks won (input #3) is greater than or equal to 6 + the bid in the contract (the number 1…7 within input #2)

1 Like

Thank you !

I was also stuck on this point, it’s not very clear in the statement so thank you!

Hi everyone,
I’m having trouble with test cases 06, 07, and 08.
Tests 1-5 pass, but I suspect the issue lies with the “Doubling” logic in Bridge scoring.
Despite reviewing the rules several times, I’m still struggling to pinpoint the problem.
My code fails with these inputs from test case 06:

  • “V 3NTXX 10”
  • “V 3CX 10”
  • “NV 1DXX 9”

Any insights would be greatly appreciated!

I’m finding this challenging and could use a fresh perspective.
Thanks in advance!

Can you show the details of the score calculations for the inputs you’ve failed? Something like this:

“NV 4HXX 10”:
4 x 30 (contracted tricks, Hearts) x 4 (redoubled) +
300 (non-vulnerable game bonus) +
100 (redoubled additional bonus)
= 880

We can then check which areas go wrong.

Here is the detailed breakdown you requested:

  • “V 3NTXX 10”:
    100 (contracted tricks, NT) x 4 (redoubled) +
    500 (vulnerable game bonus) +
    100 (redoubled additional bonus) +
    200 (overtricks)
    = 1200

  • “V 3CX 10”:
    3 x 20 (contracted tricks, C) x 2 (doubled) +
    500 (vulnerable game bonus) +
    50 (doubled additional bonus) +
    100 (overtricks)
    = 770

  • “NV 1DXX 9”:
    1 x 20 (contracted tricks, D) x 4 (redoubled) +
    50 (non-vulnerable game bonus) +
    100 (redoubled additional bonus) +
    200 (overtricks)
    = 430

Thank you so much for helping.

  • “V 3NTXX 10”:
    100 (contracted tricks, NT) x 4 (redoubled) +
    500 (vulnerable game bonus) +
    100 (redoubled additional bonus) +
    200 (overtricks) ← should be 400 because “These numbers are themselves doubled for redoubled contracts.”
    = 1200 ← hence should be 1400

  • “V 3CX 10”:
    3 x 20 (contracted tricks, C) x 2 (doubled) +
    500 (vulnerable game bonus) +
    50 (doubled additional bonus) +
    100 (overtricks) ← should be 200 because vulnerable
    = 770 ← hence should be 870

  • “NV 1DXX 9”:
    1 x 20 (contracted tricks, D) x 4 (redoubled) +
    50 (non-vulnerable game bonus) +
    100 (redoubled additional bonus) +
    200 (overtricks) ← should be 400 because “These numbers are themselves doubled for redoubled contracts.”
    = 430 ← hence should be 630

1 Like

Thanks to you! You pointed out a detail I kept missing despite reading the description multiple times. With your help, I solved the puzzle with a 100% score!

1 Like