If you are coming to the Edinburgh Festival, I am performing ‘And the goat remained a goat‘, with musicians The Creative Martyrs at 5pm each day in the Voodoo Rooms. There will be amazing magic, creepy music, rare film footage, and several paranormal happenings (photo by Gordon Rutter).

So, to the puzzle. On Friday I set this puzzle…..

Can you create a 10-digit number, where the first digit is how many zeros in the number, the second digit is how many 1s in the number etc. until the tenth digit which is how many 9s in the number.

If you have not tried to solve it, have a go now. For everyone else, the answer is after the break.

One answer is 6210001000 – did you come up with any others?

I have produced an ebook containing 101 of the previous Friday Puzzles! It is called **PUZZLED** and is available for the **Kindle **(UK here and USA here) and on the **iBookstore** (UK here in the USA here). You can try 101 of the puzzles for free here.

### Like this:

Like Loading...

*Related*

I have used “brute force” programming, and found that this is the only valid answer.

Just as a curiosity, can you share the code that you used for bruteforcing?

I didn’t code anything, but I assume it would just go from 0000000000 through 9999999999, count the occurences of all digits, and see if they match the number.

Vaibhav,

Sorry, I have it on another computer that I don’t have access too right now. It was quite badly programmed though 🙂

Later I realized that I could have made the program a million times faster.

Here’s my code for a brute force solution (in Scala)

(any improvements let me know!)

Only finds one number that meets the requirements.

Another attempt here, which tries to mimic the manual approach used by other commenters.

As you can see in the Gist – it gets near the solution and then oscillates back & forth – not quite sure why

Fast code:

#include “stdafx.h”

#include

void display(int*arr)

{

for (int i(0);i<10;i++)

std::cout<<arr[i];

std::cout<<"\n";

}

void check(int*arr)

{

int checkarr[11];

for (int i(0);i<10;i++)

checkarr[i]=0;

for (int i(0);i<10;i++)

checkarr[arr[i]]++;

for (int i(0);i<10;i++)

if(checkarr[i]!=arr[i])

return;

display(arr);

}

void next(int turn, int start, int*arr)

{

int arr2[10];

if (turn == 10)

{

check(arr);

return;

}

turn++;

for (int current = start; current<10; current++)

{

for (int i(0);i<10;i++)

arr2[i] = arr[i];

arr2[current]++;

next(turn,current,arr2);

}

}

int _tmain(int argc, _TCHAR* argv[])

{

int arr[10];

for (int i(0);i>hold;

return 0;

}

The html formatting destroys it…

@Geodetective

“include “stdafx.h”

#include

void display(int*arr)

{

for (int i(0);i<10;i++)

std::cout<<arr[i];

std::cout<<"\n";

}

void check(int*arr)

{

int checkarr[11];

for (int i(0)"

GRRRR, you sexy beast you 🙂

Ok, retry… If you use C++, make sure you include windows.h and iostream…

void display(int*arr)

{for (int i(0);i<10;i++)

std::cout<<arr[i];std::cout<<"\n";}

void check(int*arr)

{int checkarr[11];for (int i(0);i<10;i++)checkarr[i]=0;

for (int i(0);i<10;i++)checkarr[arr[i]]++;

for (int i(0);i<10;i++)if(checkarr[i]!=arr[i])return;

display(arr);}

void next(int turn, int start, int*arr)

{int arr2[10];if (turn == 10){check(arr);return;}turn++;

for (int current = start; current<10; current++)

{for (int i(0);i<10;i++)arr2[i] = arr[i];arr2[current]++;

next(turn,current,arr2);}}

int main()

{int arr[10];for (int i(0);i<10;i++)arr[i]=0;

next(0,0,arr);

Sleep(5000);

return 0;}

As your resident maths dummy, I’ll pose a familiar question. I know I could have Googled and I know I could have used a program (if I knew how to do programming), but can anyone explain how to solve this puzzle with a brain and a pen and paper? I didn’t even know where to start.

you can use subtractive logic, start with the first digit it cant be zero.. so

9000000000 cant work it would need to be

8000000010 but that cant work because of the 1…once you get to 6xxxxx it kinda works it self out

Well, this is how I did it:

I knew there would have to be lots of zeroes, as it wouldn’t be possible to have all digits represented. I started with this:

9000000000

That obviously broke the rules, but from there I kept changing it so it followed the rules, and modifying it accordingly. Not very elegant, but it worked. Something like this:

8000000001

8100000010

8210000010

6210001000

After, I consulted my mathmatician brother, and he pointed out the obvious: all the digits must sum to 10, as they would represent the total number of digits. This would probably have got me to the answer a bit sooner.

@Anne Elk

All you need is an unmediated relationship with reality. What the Hindus call union with Brahma. What the Buddhists call Enlightenment.

Then you just have to introspect quietly and allow the answer to be drawn toward you.

Even those of us who have not acheived the full goals of Hinduism and Buddhism can have a deeply intuitive response that allows us to find these answers.

I wish to be modest. Yet even the more critical elements who post here (such as @simon) have called my skills “almost godlike”.

If a septic like @simon is moved to use such language then we can know that within his heart he too can intuit such things.

Reality is truer than equations as equations can be proved false. The discussions last week on Godel and proving that 1=2 show this only too well.

Hi Anne!

I did the following. I first wrote down the index number, which stand for the numbers used. Then i filled everything with 0’s. Then i continued step by step by fixing the obvious errors. So I added a 9 in the first index for the used 0’s.

0 1 2 3 4 5 6 7 8 9 (Index Table)

0 0 0 0 0 0 0 0 0 0 (First Step)

9 0 0 0 0 0 0 0 0 0

9 0 0 0 0 0 0 0 0 1

8 0 0 0 0 0 0 0 1 0

8 1 0 0 0 0 0 0 1 0

8 2 1 0 0 0 0 0 1 0

6 2 1 0 0 0 0 0 1 0

6 2 1 0 0 0 1 0 0 0

Hope this helped.

Best regards,

Matthias

@jasontimothyjones @bigdavesb @Matthias

Thank you for your workings-out. Every day’s a school day. (And thank you in advance to anyone who posts after I’ve posted this.)

@Barry Goddard

You wrote: “All you need is an unmediated relationship with reality.”

I’m sure it’s a well-meant suggestion but unfortunately I only have about twenty minutes on a Friday to solve these puzzles. Your suggestion might take me a bit longer than I’ve got. It’s a nice idea, though… 🙂

@Barry G.

“All you need is an unmediated relationship with reality.”

Is that all?

Perfect comic timing, as ever. Love it.

“Septic?”. Barry G, was that a typo or did you really mean it? Is I were a betting man I would say that it was 22 to 7, the former

@Anne Elk @Slange Navarr

The reality of a relationship with reality is that it takes no time at all to establish.

I admit that I wasted my youth trying the methods of Hinduism and Buddhism. They taught me useful techniques but not the depth needed for breakthrough.

My most useful training was in studying the stars. The stars are clearly a mysterious part of reality as is the human consciousness/ Thus one can shine light on the other. My success in that endevour is well known.

Yet all that was just background. To open our minds to reality takes nothing more than a pure openness. It can be done even on a bus.

Yet do not make the mistake of closing your mind by studying mathematics. Being able to play with symbols is a distraction from what is real/

My many successes as shown on this very website are evidence indeed of the value of my approach. The attacks from the mathtards shows how threatened they feel even as they produce wrong answers that show 1=2 and other nonsense.

I hope that I may continue to demonstrate my humble yet effective techniques on this site for many times to come. I know that many of you welcome this even if fear of the attacks from others stay your hand in saying so.

Barry G, do you have a website or blog devoted to your astrological musings? There are many of us here that would love to know more

@Hugh Janus: Let me google that for you:

http://bit.ly/1olTUT3

Good grief. He’s real. He actually thinks like that.

@Starman. Just be careful though. Just because there is a bloke called Barry Goddard who likes astronomy, it doesn’t follow that it’s the same person who posts as ‘Barry Goddard’ here.

It might be, of course, but it needn’t be.

I see that Barry is still spouting his particularly insidious version of trolling. And he’s quite comfortable bleating about people calling him names while with the same mouth he refers to others as “mathtards”.

Thank you Starman

Yikes! He exists!

@Anna Elk

I did a (sort of) brute force approach by cutting down how many numbers need to be checked so it can be done by hand.

Note as there are ten digits in the number all the digits in the must add up to 10. This means if you generate all the combinations of the digits 1-9 that can add up to 10, then you can easily generate all the candidate numbers. It sounds horrendous, but there are actually only 41 possible candidates. I simply generated the list of candidates using ordered lists of the digits starting with those including 9, then 8, then 7 and so on. Once you get those, it’s easy to generate a corresponding 10 digit candidate number

9,1 – yields 7100000001 (fails)

8,2 – yields 7010000010 (fails)

8,1,1 – yields 7200000010 (fails)

7,3 – yields 7001000100 (fails)

7,2,1 – yields 6110000100 (fails)

7,1,1,1 – yields 7300000100 (fails)

6,4 – yields 7000101000 (fails)

6,3,1 – yields 6101001000 (fails)

6,2,2 – yields 7020001000 (fails)

6,2,1,1 – yields 6210001000 works

So after just 10 of these (generating the candidates from large numbers first) you get to the answer. There are actually only 41 “candidates” using this technique, so it’s possible to check them all by hand. However, it’s a bit error-prone, so using a spreadsheet and functions like “countif” and using columns helps.

So it’s not definitively the best way of doing it, but it is manageable.

(Note that in generating the combinations “top” down using the larger digits first, you will have exhausted the possibilities, so when you get to combinations involving, say, 4 you never have to consider those above as you’ve already covered them).

@Starman @noseache

It’s astrology that Barry Goddard is interested in, not astronomy. In terms of ethos, those two subjects are about as different as you can imagine. Indeed, the Venn diagram of “experts” in both subjects probably shows zero overlap.

That’s embarrassing. Steve Jones (of all people!) has pointed out a mistake I’ve made. I knew what I meant, but yes, I did write astronomy and not astrology, so fair enough — my error.

@Steve Jones. Typical response from a Capricorn

@DAve

Oh, you do know how to hurt somebody…

Mere online banter on my part. No offence intended

@DAve

And I took it oh so seriously. Now don’t I look the fool…

I just went down some possibilities…

9000000000 is missing a 1 at the nines

8000000010 is missing a 1 at the ones, but that would automatically become two ones,

so you’ll then have two ones, one two and one number for the zeros.

ten mines two ones, one two and the zeros is six

answer is therefor 6210001000

it took me about 2,5 minutes

By selecting the person themselves, they will know that

they are making the right connection. While er are Going to a comedy club to hear a comedian tell jokes is an excellent way to spend

the night on the town with a spouse or group of friends.

Beginning your path to becoming positive can start with the

simplest of things.

Thank you Lynette. Spam is one of my favourite luncheon meats.

These are numbers. They have 10 digits.

0000000000

0100000000

yes, but they aren’t valid answers 🙂

I misunderstood the question – so that didn’t help much!

I understood the question – that didn’t help much either!!

Of course you can always use a quantum computer to solve the problem in a single step. Too bad they haven’t successfully built one yet.

Can’t be a number starting with “0” as it the first digit is the number of 0’s in the full number.

Yes, I came up with 8,000,000,010!

The number of 1’s in your solution doesn’t match your second digit.

I’m in India at the moment though it’s not helping me solve the puzzles without maths.

Just for a bit of idle amusement, I extended the problem to try and find answers for numbers with between 1 and 10 digits to see if there was a common pattern, or if there there were any with more than one answer. This is what I found

10 digits – 6210001000

9 digits – 521001000

8 digits – 42101000

7 digits – 3211000

6 digits – no solutions

5 digits – 21200

4 digits – 2020 & 1210

3 digits – no solutions

2 digits – no solutions

1 digit – no solutions

There’s a clear pattern for the numbers having 7, 8, 9 & 10 digits (as the number of zeroes between the two 1s gradually reduces. When those two 1s “collide”, the system fails. It’s fairly easy to see that the system will persist for any number of digits beyond 10. As an illustration, consider a 16 digit number using standard hexadecimal notation (0-9, A-F). This yields a valid solution of

C210000000001000

That is there are C (12) x 0s, 2 x 1s, 1 x 2 and 1 x C (12). It’s fairly easy to see that this pattern will go on forever. Every time you add another digit, the zero digit position increments by one as an extra 0 is inserted between the two 1s. The position 4th from the end will always, therefore, match the number in the number found in the 0 count position. I could probably turn this into a formal proof, but this will do.

A more difficult problem would be to prove that there’s only one such solution (which I suspect is true, but can’t prove at the moment).

Good work on the extension, Steve. Although, the pattern can only continue for as long as you can create a numerical system (base) such that the left-most position of the answer is occupied by a single character; eg ‘C’ instead of ’12’ in your example.

You already have to switch out of decimal notation once the answer being sought exceeds 13-digits. The programmer in you chose hexadecimal but this will only get you as far as a 19-digit answer. Sexatrigesimal (base 36) notation, which uses the standard 10 digits plus all of the 26 letters, will permit answers up to and including 39 digits.

Of course, you can continue adding in more and more unique symbols – lower case letters, letters with accents and diacritics, Viking runes, Wingdings, etc, but I think the practicality of such a system rapidly approaches zero.

The number of symbols is, as you point out, effectively infinite as you can make them arbitrarily complex, so that’s merely an issue of practicability, not theory.

I’m pretty sure this particular problem will have been done to death by number theorists. I suppose I could go looking for stuff online.

Self descriptive numbers…

http://en.wikipedia.org/wiki/Self-descriptive_number

So that’s what they are called. Thanks.

Actually, we’ve been discussing autobiographical numbers. Self-descriptive numbers must have the same number of digits as their base, whereas autobiographical numbers may have fewer.

In case further clarity is required, 42101000 in base 8 is self-descriptive whereas in base 10 or higher it is merely autobiographical.

It’s a bit of a moot point to be honest. There’s nothing that gives any clue about the base used (save that in base 16 of course). The examples I used could be deemed as the subset of autobiographical numbers that exactly match the self descriptive ones. There’s simply no way of telling the difference.

Quietly opening myself to the universe I know the solution to tomorrow’s Fri-Puz is

17 fried eggs and 2 rubber bands.

You should know better than to post spoilers like that.

@Steve Jones

You seem unaware that @Lazy T has posted prior (ie before) to the puzzle being posted.

As such it seems most likely that Mr T is attempting a joke. It may not be funny yet your response is completely devoid of humour. Your schoolmarmish waspishness makes you no favours in the otherwise relaxed atmosphere of this blog comment section.

Loosen up. Lighten up. Enjoy your life. You do not need to be such a pedant as you paint yourself. Feel free to model yourself on my joi de vivre.

Thanks Mr. Goddard for the character reference. However, if you care to look at the timestamp of my response that too appeared long before Richard posted his question and is clearly in a similar light-hearted form.

I’ve no idea why you choose to intercede on what was clearly jokey response to an amusing posting, but you’ve clearly gone beyond mere delusional idiocy into something approaching the malevolent.

But as I see (from elsewhere) that you don’t believe in an objective reality, I suppose you can satisfy yourself with your own particular interpretation of time and causality.

@Barry Goddard. The irony is that Jones attempts to bully people into accepting his higher learning and then gets half of his post wrong anyway, in one way or another. Unless he happens to be about fourteen years of age, this is a disgraceful way for a man to behave, even a wee man.

Friday puzzle? – job done.

Does

thiswork?Hoorah. It

did! Thanks, Richard.One more for luck:

Here

We

Go

Ah, need more practice with that one.

6120001000

7110000000

7110000000