Problem 43969. Sleeping Queens 1

My youngest daughter received a card game named Sleeping Queens for Christmas this year, and has been playing it nearly non-stop since opening it.

You are dealt five cards, most of which have numbers 1-10 on them. There are other cards, but for now we will just deal with the numbers. You can discard cards in any of three different methods and draw that many new cards:

  • Individual cards, one at a time
  • Pairs of cards, but not three or four of a kind
  • Cards that make up an addition problem.

Write a MATLAB script that will tell you how how many different ways you can discard cards in your hand.

For example, if your hand had the cards [1 2 2 4 9], you could discard

  • Any of the cards individually (5)
  • The pair of 2s (1)
  • [2 2 4] because 2+2=4 (1)
  • [1 2 2 4 9] because 1+2+2+4=9 (1)

so your script would output 8. Likewise, a hand of [1 2 2 2 6] would allow you discard cards 9 different ways:

  • Any of the cards individually (5)
  • Any of the three different pairs of 2s (3)
  • [2 2 2 6] because 2+2+2=6 (1)

So the output of your script for [1 2 2 2 6] should be 9. We don't need to know what the possible combinations are to discard just yet; we just need to know how many there are. Good luck, and happy hunting!

Solution Stats

59.62% Correct | 40.38% Incorrect
Last Solution submitted on Mar 05, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers21

Suggested Problems

More from this Author80

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!