Cody

Problem 2318. Combine Cards to make 21

Created by James Kristoff in Card Games

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

49.18% Correct | 50.82% Incorrect
Last solution submitted on Jun 13, 2018

Problem Comments

Solution Comments

Recent Solvers20

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!