[Tutor] List all possible 10digit number

Dwight Hutto dwightdhutto at gmail.com
Sat Sep 1 07:20:38 CEST 2012


Dear Scurvy,
    I don't know if this has been suggested yet, but I just broke the
larger list of 10 digit nums into segments, and at the end of the loop,
kept the previous last num in the segment as the beginning of the next
range() that goes through the same amount of ints in each segmentation of
the larger list to iterate through.

Except the next list of ints is starting where the last set segmentation of
possible length int segments ends, and keeps iterating through all possible
nums until it hits a match high_num.

The following goes through 10,000 element lists until it hits a target
high_num, which in this case is 1,000,000.



def iterToHighNum(increment,high_num):
    end_point = 0
    a = [i for i in range(0,increment)]
    while (end_point != high_num) == True:
        for integer in a:
            if integer != high_num:
                #print "no match, integer = %i" % (integer)
                end_point += 1
            if end_point == high_num and integer != (high_num - 1):
                print 'match, integer = %i, high_num = %i' %
(integer,high_num)

        previous_increment = increment
        increment += increment
        a = [i for i in range(previous_increment,increment)]

#instance
increment = 10000
high_num = 1000000
iterToHighNum(increment,high_num)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120901/0ba3d49d/attachment-0001.html>


More information about the Tutor mailing list