Sleeping Queens 1 - MATLAB Cody - MATLAB Central

Problem 43969. Sleeping Queens 1

Difficulty:Rate

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

39.0% Correct | 61.0% Incorrect
Last Solution submitted on Feb 22, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
2
4
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Physics Image
Physics
  • 18 Problems
  • 13 Finishers

Problem Recent Solvers28

Community Treasure Hunt

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

Start Hunting!
Go to top of page