In blackjack each card holds a numerical value for the points it represents:
Ace => could be 1 or 11 (I was assuming that in this case it is always 1)
2-9 => Their face value is the same
10, Jack, Queen & King => 10.
The protocol handles these calculations by module of 13 (the 13 cards). It then checks to see which card it is Ace, King and everything in between.
The vulnerability lies with the dealersHand
function. Unlike the playersHand
function, it does not check for the cardValue to be 0 (which would be the case for a King card as it is the 13th, 26th, 39th, 52nd card - all multiplications of 13).
Consider these following scenarios:
Dealer has a 2 and a 13 (2 and king). Calculations will give a total of 15.
Dealer has a 2 and a 26 (2 and king). Calculations will give a total of 28.
Dealer has a 2 and a 39 (2 and king). Calculations will give a total of 41.
Dealer has a 2 and a 52 (2 and king). Calculations will give a total of 54.
In the first scenario the result is a bad one to try and win the match. However, in all of the other ones it is a sure loss! Guaranteeing a win for the player almost every time the dealer has been dealt a king.
Manual Analysis
As the playershand
function add the following code to the first if statement:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.