| * There are about 30 numbers with one bit "on" in the appropriate range, and
none is a decimal permutation.
* There are about 30**2 numbers with two bits "on" in that range, and none is
a decimal permutation.
* There are about 30**3 numbers with three bits "on" in that range, and 3 of
them ARE decimal permutations:
2**0 + 2**20 + 2**32 = 4296015873
2**1 + 2**21 + 2**33 = 8592031746
2**2 + 2**30 + 2**32 = 5368709124
The whole thing runs in a few seconds (30**3 is not much..). To check whether
a 10 digit number is a permutation you need a single pass on its digits,
turning on (.OR.) one of 10 flag bits for each digit, and finally see if you
got flag = '1111111111'B (= 1023).
Also, to check for MAXIMUM number of bits instead of minimum, I think the
complementary method will work: Produce numbers with one bit "off" (by
SUBTRACTION of different powers of 2 from 111...111), and then with two bits
"off", etc.
????
NITSAN
|
| On a side note, there are 33 bits in a ten digit (decimal) number. In which
case there are 33!/(32!*1!) = 33 with one bit on, 33!/(30!*2!) = 528 with
two bits on, 33!/(29!*3!) = 5456 with three bits on. That's less than the
estimates given in .1. To write a program that can remove the duplicates
efficiently is left as an exercise to the reader.
Wim
|