Problem 2318. Combine Cards to make 21
Given between two and six cards, e.g.
A _ 3 _ 7 _ 6 _ 2
place one of the mathematical symbols (+,-,*,/) in the space between each pair of cards to make the equation equal 21.
The input will be a string, e.g.
- 'A3762'
The output should be a cell array of mathematical symbols in the order that satisfies the puzzle, e.g. for the string given above, the output would be:
{'+-*/'}
Which means that A + 3 - 7 * 6 / 2 = 21.
- A + 3 = 14
- 14 - 7 = 7
- 7 * 6 = 42
- 42 / 2 = 21
Rules:
- The Ace can represent either 1 or 11.
- All operations should be performed from left to right
- Cards will be represented by the characters: A,2,3,4,5,6,7,8,9,J,Q,K
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
James Kristoff
on 16 May 2014
Thanks for the suggestion Alfonso. That does make things a little more challenging. :)
J.R.! Menzinger
on 19 May 2014
Did you have fun this this last test case, isn't it?? XDDD
YOU... BAD GUYS!! ;-)
Rafael S.T. Vieira
on 13 Sep 2020
J,Q, and K all have value 10. This rule should be probably added to the problem description.
Solution Comments
Show commentsGroup

Strings II
- 21 Problems
- 41 Finishers
- Eliminate Polysyllabics: Long live short words!
- Alternately upper-lower case
- Morse Code Generator! Try it!
- Is the paranthesis sequence balanced ?
- Simple Decoder Ring
- Join Strings with Multiple Different Delimiters
- Is the paranthesis sequence balanced ?
- Count letters occurence in text, specific to words with a given length.
- Convert Two Character String into a Binary Vector
- Kryptos - CIA Cypher Sculpture: Vigenere Encryption
- Kryptos - CIA Cypher Sculpture: Vignere Decryption
- Mean and standard deviation of times in string
- How many digits are there?
- ABBREVIATION
- Make a list string
- Generate a melodic contour string matrix
- Morse Code Generator! Try it!
- NO _________ ALLOWED....
- Backslang, odds are you used it at some point in time...
- Simple Caesar Cypher - shift encrypt a message given an index number
- Split a given string from the first instance of a given character
- Concatenate strings
- most frequent character
- Alternately upper-lower case
Problem Recent Solvers37
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!