Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Steven D'Aprano
On Sun, 18 Jul 2010 11:51:17 am Richard D. Moores wrote: [...] > > On my not-even-close-to-high-end PC, this generates one billion > > digits in 22 minutes: > My took 218 secs. Lucky for some :) Your version, on my machine, took 16 minutes, an improvement

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Richard D. Moores
On Sat, Jul 17, 2010 at 18:01, Steven D'Aprano wrote: > Having generated the digits, it might be useful to look for deviations > from randomness. There should be approximately equal numbers of each > digit (100,000,000 each of 0, 1, 2, ..., 9), of each digraph > (10,000,000 each of 00, 01, 02, ..

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Steven D'Aprano
On Sun, 18 Jul 2010 06:49:39 pm Richard D. Moores wrote: > I might try > trigraphs where the 2nd digit is 2 more than the first, and the third > 2 more than the 2nd. E.g. '024', '135', '791', '802'. Why the restriction? There's only 1000 different trigraphs (10*10*10), which is nothing. > Or

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Dave Angel
Richard D. Moores wrote: On Sat, Jul 17, 2010 at 18:01, Steven D'Aprano wrote: import random def random_digits(n): "Return n random digits with one call to random." return "%0*d" % (n, random.randrange(10**n)) Thanks for implementing what I was suggesting, using zero-fill for

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Richard D. Moores
On Sun, Jul 18, 2010 at 02:26, Steven D'Aprano wrote: > On Sun, 18 Jul 2010 06:49:39 pm Richard D. Moores wrote: > >> I might try >> trigraphs where the 2nd digit is 2 more than the first, and the third >> 2 more than the 2nd. E.g. '024', '135', '791', '802'. > > Why the restriction? There's only

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Steven D'Aprano
On Sun, 18 Jul 2010 08:30:05 pm Richard D. Moores wrote: > > Taking the string '555', you should get two digraphs: 55_ and _55. > > That seems wrong to me. When I search on '99' and there's a > '999' I don't want to think I've found 2 instances of '99'. > But that's just my preference.

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Richard D. Moores
On Sun, Jul 18, 2010 at 05:49, Steven D'Aprano wrote: > On Sun, 18 Jul 2010 08:30:05 pm Richard D. Moores wrote: > >> > Taking the string '555', you should get two digraphs: 55_ and _55. >> >> That seems wrong to me. When I search on '99' and there's a >> '999' I don't want to think I've f

Re: [Tutor] Return error message for my script in Blender

2010-07-18 Thread Andrew Martin
Yeah ok I get it. I have to return something. I looked at the sample code provided on the book's website and found out what I am supposed to return. Thanks. I appreciate the responses, especially to this bonehead question. ___ Tutor maillist - Tutor@py

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread R. Alan Monroe
> That's the goal of the latest version of my script at > . The best I've been able to do > so far is a file with 800 million digits. I don't think anyone else has suggested this: the numpy module can generate random bytes and has a built-in tofile() method.

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread bob gailer
Check this out: import random, time s = time.time() cycles = 1000 d = "0123456789"*100 f = open("numbers.txt", "w") for i in xrange(n): l = [] l.extend(random.sample(d, 1000)) f.write(''.join(l)) f.close() print time.time() - s 1 million in ~1.25 seconds Therefore 1 billion in ~21 minutes

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Alan Gauld
"Richard D. Moores" wrote I earlier reported that my laptop couldn't handle even 800 million. What do you mean, "couldn't handle"? Couldn't handle 800 million of what? Obviously not bytes, I meant what the context implied. Bytes. Look back in this thread to see my description of my laptop's

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Dave Angel
Steven D'Aprano wrote: On Sun, 18 Jul 2010 08:30:05 pm Richard D. Moores wrote: What do you mean, "couldn't handle"? Couldn't handle 800 million of what? Obviously not bytes, because your laptop *can* handle well over 800 million bytes. It has 4GB of memory, after all :) This is just