Problem 43676. Count the Digits in the Box

In this problem you must provide an accurate census of all the digits inside a given box. The problem is complicated by the fact that your census report also appears inside the box, thereby influencing the result. Here is the simplest form of the problem.

 ----------------------------------------------
 |  The number of 0's inside the box is: ___  |
 |  The number of 1's inside the box is: ___  |
 |  The number of 2's inside the box is: ___  |
 |  The number of 3's inside the box is: ___  |
 |  The number of 4's inside the box is: ___  |
 |  The number of 5's inside the box is: ___  |
 |  The number of 6's inside the box is: ___  |
 |  The number of 7's inside the box is: ___  |
 |  The number of 8's inside the box is: ___  |
 |  The number of 9's inside the box is: ___  |
 ----------------------------------------------

Suppose you start to fill it in like this: there's only one 2, so you put a 1 next to the 2. But there are now two 1's, so you put a 2 next to the 1. But now there are three 2's... and so on. This problem eventually converges and can be answered as follows.

 --------------------------------------------
 | The number of 0's inside the box is:   1 |
 | The number of 1's inside the box is:   7 |
 | The number of 2's inside the box is:   3 |
 | The number of 3's inside the box is:   2 |
 | The number of 4's inside the box is:   1 |
 | The number of 5's inside the box is:   1 |
 | The number of 6's inside the box is:   1 |
 | The number of 7's inside the box is:   2 |
 | The number of 8's inside the box is:   1 |
 | The number of 9's inside the box is:   1 |
 --------------------------------------------

Count the numbers and you'll see the sums all work out. We will complicate this problem by adding some extra numbers to the top of the box.

Example

If

 extras = 22222

then we can see by inspection that one solution is

 census = [1 7 7 2 1 1 1 3 1 1]

as shown below

 --------------------------------------------
 | Here are some extra numbers:       22222 |
 | The number of 0's inside the box is:   1 |
 | The number of 1's inside the box is:   7 |
 | The number of 2's inside the box is:   7 |
 | The number of 3's inside the box is:   2 |
 | The number of 4's inside the box is:   1 |
 | The number of 5's inside the box is:   1 |
 | The number of 6's inside the box is:   1 |
 | The number of 7's inside the box is:   3 |
 | The number of 8's inside the box is:   1 |
 | The number of 9's inside the box is:   1 |
 --------------------------------------------

In general, your answer might not be unique. We'll just test whether you meet the criteria.

Solution Stats

27.38% Correct | 72.62% Incorrect
Last Solution submitted on Nov 11, 2021

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers6

Suggested Problems

More from this Author50

Problem Tags

Community Treasure Hunt

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

Start Hunting!