Post Reply 
Numbers of Armstong WP34s
07-30-2018, 12:58 AM
Post: #8
RE: Numbers of Armstong WP34s
I had solved Armstrong Numbers problem many years ago.

It searched all Armstrong Numbers (digits > 1) in 6 minutes on my laptop.
That is a huge 10^60 search space !

This is the gist of my routine:

If pattern 543 is checked, other permutations (345, 354, 435, 453, 534) can be skipped.
All permutations is going to produce the same sum anyway. So, 1 check = 3! = 6 tests

Digits pattern not reached 3 digits can be skipped: 100 110 111, 200, 210, 211, 220, ..., 432

Sum of over 3-digits can also be skipped: 964, 965, 966, 970, 971 ..., 988, 990, ... 999

Patterns to check = 433, 440, 441 ..., 963 (*)

The trick is to design how the pattern incremented.
You can guess the algorithm from above example.

Have you seen it ?
Combinatorial problem is fun ! :-)

(*) my code actually search to 988
To speed up the code, it need a simple test for endpoint.
So, the loop stop if the next pattern had too many 9's in it.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Numbers of Armstong WP34s - ggauny@live.fr - 11-30-2015, 07:02 PM
RE: Numbers of Armstong WP34s - Albert Chan - 07-30-2018 12:58 AM



User(s) browsing this thread: 4 Guest(s)