Re: My own accounting python euler problem
by Ozz other posts by this author
Nov 8 2009 4:27AM messages near this date
Re: My own accounting python euler problem
|
Re: My own accounting python euler problem
Oops,
> For listing all different subsets of a list (This is what I came up
> with. Can it be implemented shorter, btw?):
>
> def subsets(L):
> S = []
> if (len(L) == 1):
> return [L, []]
better to check for the empty set too, thus;
if (len(L) == 0):
return [[]]
The order of the sets looks better too;
> >> subset.subsets([1,2,3])
[[], [1], [2], [2, 1], [3], [3, 1], [3, 2], [3, 2, 1]]
cheers,
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Vsoler
Ozz
Raymond Hettinger
John Machin
Steven D'Aprano
Steven D'Aprano
John Machin
Mel
Steven D'Aprano
Geremy Condra
Gerry
Mrab
Mrab
Vsoler
Ozz
Dan Bishop
Ozz
Geremy Condra
Geremy Condra
Ozz
Ozz
Robert P. J. Day
Martin P. Hellwig
Robert P. J. Day
Robert P. J. Day
Jack Diederich
|