 # The BlackJack with conditions. @ Dcoder

By Lochard | As a newbie programmer | 21 Jul 2023

Problem: Write a program to play a variety of BlackJack. In general, given two numbers, a and b, return their sum.

If the sum is greater than 21, return 0, unless one of the numbers is 11. In such a case, the 11 should be 'converted' to a 1 to prevent the sum from being exceeded.

For example, given a 11 and 13 as input, the 11 should be 'converted' into a 1 so the total sum will be 14.

Input: Input contains 2 space separated integers, a and b

Output: Output will be in general sum of a and b, if sum exceed 21, return 0, unless one of the numbers is 11. In such a case, the 11 should be 'converted' to a 1 to prevent the sum from being exceeded.

For example, given a 11 and 13 as input, the 11 should be 'converted' into a 1 so the total sum will be 14.

Constraints: 0<=a<50

0<=b<50

Sample Input: 11 13

Sample Output:

14

``````a, b = map(int, input().split())
s = a + b
if s > 21 and 11 in (a, b):
s -= 10
print(s if s < 22 else 0)`````` Lochard

Asylum seeker in Lithuania. My short-lifed daily on GitHub https://github.com/locharp/asylum_daily/tree/main/en As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets Send a \$0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.