|Short & Sweet Math Challenge #10: Counting beans|
Message #1 Posted by Valentin Albillo on 2 June 2005, 12:37 p.m.
This new S&SMC #10 completes the "trilogy" of find-the-number style challenges,
and once again, we're looking for a 10-digit integer number (what else ?) and the answer is
unique. So grab your favorite HP (preferably) calculator/handheld and do write a program for it to try and solve
Find a 10-digit integer number such that its 1st digit counts the number of 0's in the
whole number itself, its 2nd digit counts the number of 1's, and so on till its 10th digit, which counts the number of 9's present. For example, this would be a solution:
were it not for the fact that there are two "0", not three; there's a single "1", not five,
there's a single "2", not four; etc, etc.
The solution is unique. Numbers beginning by one or more "0"'s are *not* 10-digit numbers.
As usual, you're expected to produce a program for your chosen calculator(s) that upon running will find the one and only solution. There's no need to let it run till it makes sure there are no others, but if you want to, so much the better.
Midway next week I'll post my solution (plus comments), which is a simple 5-line program for the HP-71B which finds the only solution in an average time of 15 seconds (nearly instantaneous under Emu71). It uses very, very little programmer's insight (see Recommended Guidelines, below), just the bare minimum and obvious heuristic to speed up the search. I may also provide an HP42S and/or HP-41C and/or HP-15C solution if available time permits. You'll have the whole weekend and then some to try your hand at it.
So keep your heuristics simple and show instead your programming muscle (if any), not your own puzzle-solving abilities. Try to consider yourself a puzzle-solver dummy but an HP-calc programmer genius, and see what comes out. Or else.
- Absolutely refrain from using a PC, laptop, or PDA (unless running some HP calc emulator/simulator) to solve the challenge. A Mathematica, Visual Basic, C++, or Java solution is useless to the intended purporses of this challenge, in fact actually defeats them and is to be considered unpolite on purpose.
- Refrain from using your own smarts to solve the challenge, then perpetrate a program which incorporates so much of your previous study of the problem that it has pretty little to do. In an extreme case, you find the solution entirely by hand, then your program simply prints it out !.
On a more typical example, you let the puzzle in so solved an state that the program finds it only too easy to deal with the pitiful remains. That's not it. The idea is that *the machine* does most of the work for you, *not* the other way around.
Best regards from V.
Edited to correct a major typo, doesn't affect any attempts to solve it
Edited: 3 June 2005, 8:54 a.m. after one or more responses were posted