[Tutor] List all possible 10digit number
Dave Angel
d at davea.name
Sat Sep 1 07:55:49 CEST 2012
On 09/01/2012 01:46 AM, Dwight Hutto wrote:
> Here's the better function fixed with a return statement I forgot, but
> might not be as quick as the pre-built functions already shown:
>
> 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)
> return
>
> previous_increment = increment
> increment += increment
> a = [i for i in range(previous_increment,increment)]
>
> #instance
> increment = 10000
> high_num = 1000000
> iterToHighNum(increment,high_num)
>
>
I'm not sure what the point of any of that is; you're making a simple
problem complex. If you're wanting to accomplish the task without using
any of the itertools stuff, why not just:
current = 10**9
lim = 10**10
while current < lim:
print current #or write to file, or whatever
current += 1
--
DaveA
More information about the Tutor
mailing list