Think of there being a decimal point after the first digit in each number, i.e., you’re multiplying a.bc times d.e with digits 2, 4, 5, 7, and 8. The observation that the digits be in decreasing order in each number is taken to be obvious. For simplicity, we might as well include 0 as a sixth digit, so we can assume we’re looking to maximize 8.bc times d.ef with digits 0, 2, 4, 5, and 7.

If we take d=7, the product is at least 8×7=56, whereas otherwise it is less than 9×6=54, so we now want to maximize 8.bc times 7.ef with a distribution of 0, 2, 4, and 5. The 5 now is either b or e. Clearly you get more “bang for your buck” when you multiply .5 by 8 instead of 7, so we should put it in the e position.

At this point it makes sense to move the decimal point and write the problem as 8.bc times 75.f with digits 0, 2, and 4. In this case, you get (a lot) more from multiplying .4 by 75 instead of 8, so we should let b=4. This leads to 84.c times 75.f, so the .2 gives more when it multiplies 84 than 75, and that leads to the final answer, 84 times 752.

]]>75.c * 8.e

The 4 should go to e since 75>8. Basically, the zig-zag pattern comes from shifting the digits, so you always know which side is going to be bigger and the next larger digit is placed on the other side. ]]>

Instead of a 3-digit number times a 2-digit number, divide the numbers by powers of 10 so you get, in decimal:

a.bc * d.e

Should the 8 be in d or a? Well, it is almost symmetrical, but in position d it will get to multiply 0.bc, which can be greater than 0.e. So

7.bc * 8.e

Where should the 5 go? Of course, b, so it multiplies 8 instead of 7. Then done.

I think this same logic proves the pattern for all of these problems, in all bases.

]]>No, 00987835699.

No, 00097835699.

But I can’t beat 11 digits.

]]>I actually use matplotlib, when I want a quick peek at the data. But I’ve never been able to get matplotlib to make the finished product look the way I want it to. (The seaborn module helps, but not quite enough.) Still, I really do need to join the 21st century at some point. The home-baked graphics routines I use have roots that go back 25 years — to a time when there was no Python, no SVG, no www.

New year’s resolution: I’m going to update this stuff.

I can’t explain the 503s. I haven’t seen any HTTP errors of any kind. I can only guess that the problem might have to do with your added parameters, ‘start=20′ and ‘rc=1′, which I haven’t yet tried. Maybe Google barfs when you ask for the third page of results if there are fewer than three pages?

]]>Tricky bug! Have you considered Matplotlib for outputting figures in SVG? I can’t speak to the quality of the generated XML, but it seems to render correctly in Chrome and Firefox. In any event, it could help simplify your graphics workflow some.

Here’s an attempt to replicate your first figure using only Python. I only had patience to wait for 50 samples, but I think it’s a reasonable facsimile. I also attempted to address the limitations identified by several readers regarding the accuracy of the results count.

Curiously, Google began rejecting my requests (with a 503 response) despite a 1 second courtesy pause – did you run into this issue as well?

]]>Oddly, when I googled on 25898913, I got a different result, but I did see the essential qualitative vagaries in its neighborhood. Here are the number of hits for the range 25898900-25898929 (dropping all but the last two digits of the number):

00: 5400

01: 5740

02: 3910

03: 25,000,000

04: 2630

05: 2350

06: 2190

07: 2020

08: 2190

09: 2360

10: 3590

11: 4190

12: 2300

13: 24,300,000*

14: 23,600,000

15: 25,300,000

16: 25,000,000

17: 20,400,000

18: 22,200,000

19: 27,500,000

20: 2920

21: 2250

22: 23,000,000

23: 2980

24: 34,200,000

25: 47,800,000

26: 2420

27: 19,700,000

28: 23,400,000

29: 2980

30: 5500

*Well I’ll be darned. When I did this search earlier from home (I’m composing this at a coffee shop), Google only gave 171,000 hits for 25898913. I remember that distinctly. I’ll have to check again when I get back home.

In any event, here’s what I get for the same range when I change the second digit from a 5 to a 6, i.e., when I google on 26898900-29:

00: 3840

01: 2640

02: 2220

03: 1960

04: 1970

05: 19,300

06: 1910

07: 2150

08: 1940

09: 1960

10: 2520

11: 21,000

12: 1880

13: 2150

14: 2070

15: 2130

16: 2170

17: 3540

18: 4680

19: 2660

20: 1850

21: 1820

22: 1990

23: 1780

24: 1720

25: 1770

26: 12,200

27: 2210

28: 2100

29: 2740