Thank you Dave. This does it but slowly. takes every subset of the
list a of squares, and then gets a 'partition' that will work, many
are very inefficient (with lots of 1s).
any hints about how to speed up ?
def subset(x):
for z in range(1,2**len(x)):
q=bin(z)
subs=[]
Trip Technician wrote:
Thank you Dave. This does it but slowly. takes every subset of the
list a of squares, and then gets a 'partition' that will work, many
are very inefficient (with lots of 1s).
any hints about how to speed up ?
def subset(x):
for z in range(1,2**len(x)):
On 21 Apr, 14:46, MRAB goo...@mrabarnett.plus.com wrote:
Trip Technician wrote:
Thank you Dave. This does it but slowly. takes every subset of the
list a ofsquares, and then gets a 'partition' that will work, many
are very inefficient (with lots of 1s).
any hints about how to speed up ?
Trip Technician wrote:
On 21 Apr, 14:46, MRAB goo...@mrabarnett.plus.com wrote:
Trip Technician wrote:
Thank you Dave. This does it but slowly. takes every subset of the
list a ofsquares, and then gets a 'partition' that will work, many
are very inefficient (with lots of 1s).
any hints about
MRAB:
I think I might have cracked it:
...
print n, sums
Nice.
If you don't want to use dynamic programming, then add a @memoize
decoration before the function, using for example my one:
http://code.activestate.com/recipes/466320/
And you will see an interesting speed increase, even if
bearophileh...@lycos.com wrote:
MRAB:
I think I might have cracked it:
...
print n, sums
Nice.
If you don't want to use dynamic programming, then add a @memoize
decoration before the function, using for example my one:
http://code.activestate.com/recipes/466320/
And you will see an
although it's not homework (how can i prove that...?) i am still happy
with just hints
+++
we want to express integers as sums of squares. (repeated squares are
allowed)
most numbers have one minimal representation e.g. 24=16+4+4, some have
two or more e.g. 125 = 121+4 = 100+25
so far I have
Trip Technician wrote:
although it's not homework (how can i prove that...?) i am still happy
with just hints
+++
we want to express integers as sums of squares. (repeated squares are
allowed)
most numbers have one minimal representation e.g. 24=16+4+4, some have
two or more e.g. 125 = 121+4