nextPermutation and ranges

John Colvin john.loughran.colvin at gmail.com
Fri Feb 8 16:37:34 PST 2013


On Friday, 8 February 2013 at 21:07:58 UTC, Era Scarecrow wrote:
> On Friday, 8 February 2013 at 12:27:50 UTC, John Colvin wrote:
>> On Friday, 8 February 2013 at 06:59:20 UTC, Marco Leise wrote:
>>>
>>> So right now we can handle 20! = 2,432,902,008,176,640,000 
>>> permutations. If every check took only 20 clock cycles of a 4 
>>> Ghz CPU, it would take you ~386 years to go through the list. 
>>> For the average human researcher this is plenty of time.
>>
>> On a modern supercomputer this would take well under 2 months. 
>> (I calculated it as ~44 days on Minerva at Warwick,  UK). 19! 
>> would take less than 3 days.
>>
>> In a parallel setting, such large numbers are assailable.
>
>  If we have such a large number of computations, then either 
> cent will have to be implemented, use BigInt, or an internal 
> array that handles locational information. That would remove 
> the limitations of 20 to either 255, or 65535 (assuming you 
> EVER need that many). Course rummaging through the array for 
> the next computation becomes more difficult the larger the 
> number of elements.

Seeing as 61! is of the order of the number of atoms in the 
observable universe, i don't think there's much need to plan for 
any higher than that!


More information about the Digitalmars-d mailing list