[kw-pm] Last Wednesday's meeting

Max max at alleged.net
Thu Jun 18 09:45:13 PDT 2009


My indentation apparently got et; let's try again.

import random as r
n,s=0,''
for l in open('x'):
 n+=1
 if r.random()<1.0/n:s=l
print s


Max wrote:
> The reasonably minimalistic python version (87 bytes), with input in a 
> file named 'x':
> import random as r
> n,s=0,''
> for l in open('x'):
> n+=1
> if r.random()<1.0/n:s=l
> print s
>



More information about the kw-pm mailing list