"r.e.s." <[EMAIL PROTECTED]> wrote ...
> <[EMAIL PROTECTED]> wrote ...
>> "r.e.s." <[EMAIL PROTECTED]> wrote:
>>> Can the following program be shortened? ...
>>>
>>> def h(n,m):
>>> E=n,
>>> while (E!=(
<[EMAIL PROTECTED]> wrote ...
> "r.e.s." <[EMAIL PROTECTED]> wrote:
>> Can the following program be shortened? ...
>>
>> def h(n,m):
>> E=n,
>> while (E!=())*m>0:n=h(n+1,m-1);E=E[:-1]+(E[-1]>0)*(E[-1]-1,)*n
>> return n
>>
Can the following program be shortened? ...
def h(n,m):
E=n,
while (E!=())*m>0:n=h(n+1,m-1);E=E[:-1]+(E[-1]>0)*(E[-1]-1,)*n
return n
h(9,9)
Note: Although it halts eventually in principle, this program can't be
expected to terminate on any machine in the universe, as it computes a
number lar
"Tim Chase" <[EMAIL PROTECTED]> wrote ...
> 2) use a python set:
>
> s = set()
> for line in open("file.in"):
> s.add(line.strip())
> return len(s)
>
> 3) compact #2:
>
> return len(set([line.strip() for line in file("file.in")]))
>
> or, if stripping the lines isn't a concern, it can just be
I have a million-line text file with 100 characters per line,
and simply need to determine how many of the lines are distinct.
On my PC, this little program just goes to never-never land:
def number_distinct(fn):
f = file(fn)
x = f.readline().strip()
L = []
while x<>'':
if
"Oliver Albrecht" <[EMAIL PROTECTED]> wrote ...
> Has some one an sodoku-task-generator?
Sudoku puzzles can be generated (and solved) online at
http://act365.com/sudoku/
--
http://mail.python.org/mailman/listinfo/python-list