Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

The Protocol of Small Numbers


Jun02: Dr. Ecco's Omniheurist Corner

Dennis, a professor of computer science at New York University, is the author of The Puzzling Adventures of Dr. Ecco (Dover, 1998); Codes, Puzzles, and Conspiracy (W.H. Freeman & Co., 1992); Database Tuning: A Principled Approach (Prentice Hall, 1992); (coauthored with Jason Wang and Bruce Shapiro) Pattern Discovery in Biomolecular Data: Tools, Techniques, and Applications (Oxford University Press, 1999); and (coauthored with Cathy Lazere) Out of Their Minds: The Lives and Discoveries of 15 Great Computer Scientists (Springer-Verlag, 1998). He can be contacted at [email protected].


Our client was a soft spoken, exquisitely dressed Englishman. "I'm on a royal errand," he said. "A young prince of a country that is not my own has asked me to help him with a puzzle. I am only a master of protocol, so I need your help. The problem as I have heard it described is to generate all the whole numbers from 1 to as large a number n as possible using only a single number called a 'generator.' One is allowed, I am told, to use any arithmetic operator — plus, times, minus, and divide — one wants. Parentheses are also allowed. I tell you this last point in the hope that it helps you more than it would help me. Now the goal is to generate all these numbers by using as few generator elements as possible on the average for the numbers between 1 and n. We are not told what the generator is to be and we want the largest n such that the averages can be 5, 6, and 7."

"As I see it, sir," 14-year-old Liane stated with an uncharacteristic politeness, "there are three elements to the problem: the generator k, the average number m of uses of the generator, and the largest number generated n. You give us only m and you want us to find the k that gives the largest generated n such that all numbers from 1 to n can be generated from expressions in k and the number of instances of k on the average is less than or equal to m."

"I think that's it, yes," said the visitor. "I have an economical answer using 4 as the generator and the numbers from 1 to 10. Here they are:

1: 4/4

2: (4+4)/4

3: 4-(4/4)

4: 4

5: (4/4)+4

6: ((4+4)/4)+4

7: (4+4)-(4/4)

8: 4+4

9: (4/4)+(4+4)

10: ((4+4)/4)+(4+4)

"The average number of 4s is 3.1 in this sequence. I'm not sure 4 is the best generator in general, however. Here is the same sequence with 5 as the generator:

1: 5/5

2: (5+5)/5

3: 5-((5+5)/5)

4: 5-(5/5)

5: 5

6: (5/5)+5

7: ((5+5)/5)+5

8: (5+5)-((5+5)/5)

9: (5+5)-(5/5)

10: 5+5

"So, would it be asking too much for you to find, by tomorrow at tea time, the best generator and the highest possible n such that the average number of generators used to form the numbers 1...n is no greater than 5?"

Reader: Liane was able to generate the numbers 1...57 with an average cost of just under 5. Her generator wasn't 4. Can you do as well or better?

"I can come back two days from now for an average no greater than 6 or 7."

Reader: Liane was able to get 121 with an average cost of just under 6. She was able to get 308 with an average cost of just under 7. She didn't always use the same generator. How well do you do?

Ecco turned to me after our visitor left.

"Well Professor, you see the numbers Liane has come up with: 57 for an average cost of 5, 121 for an average cost of 6, and 308 for an average cost of 7. Is there an exponential relationship with the average cost? Further, what does the average cost vary with the number of generators you are permitted to use (for example, if you used 4 and 5 together as generators instead of just 5)?

"I don't know the answers."

Reader: What do you think?

Last Month's Solution

Figure 1, Liane's solution to last month's puzzle, using six rays.

Reader Notes

The following readers proposed correct solutions to the "With Eye of Newt" puzzle (DDJ, March 2002): Pearl Pauling, Craig Stevenson, Warren Dougherty, Andrew Palfreyman, Douglas Michael Auclair, Rodney Meyer, Douglas Wilson, Mike Bandy, and Mani Iyer.

The glue-machine technology as proposed in this puzzle would be extremely useful. Physicists and chemists, please take note.

DDJ


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.