I suck pretty hard and can't figure out a way to do this, I am doing it in php, cause it's pretty much all I know..
so I tried
<?php
$v1=1;
$v2=1;
$v3=1;
$v4=1;
$v5=1;
>>2
indeed, 4 does not equal 120.
oh wait, there's a space in there. invalid lvalue in assignment.
>>1
it's really easy if you factor 120 (2*2*2*3*5)...
2*3*4*5
2*2*5*6
2*2*3*10
2*2*2*15
Name:
Anonymous2007-03-09 17:22 ID:yO9TuDQD
what no you're missing the point; I don't want to work out the factors, i don't want to do it manually. I want the program to output all 256 possibilities from 1 * 1 * 1 * 1 to 9 * 9 * 9 * 9, and display all the answers.
>>7
i don't care about stupid factors jeez blow me i can get the factors, that's not the point, or what i want.
1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120.
wow look great can you all shut up about factors now please?
I just want to know how to output all 256 possibilities.
first of all there are more than 256 unique products a*b*c*d where a,b,c,d are in {1,...,9}. there are (4+9-1,4)=495 unique products. use something like this (pseudocode):
for (a=1;a<=9;a++)
for (b=a;b<=9;b++)
for (c=b;c<=9;c++)
for (d=c;d<=9;d++)
print a*b*c*d
dont start the loops at 1 otherwise you will enumerate the same product multiple times: 2*1*1*1, 1*2*1*1, 1*1*2*1, 1*1*1*2, etc
dict.fromkeys(tuple(sorted((a, b, c, d))) for a in xrange(1, 61) for b in xrange(1, 61) for c in
xrange(1, 61) for d in xrange(1, 61) if a * b * c * d == 120).keys()
>>18
You can't be owned when you don't ask for anything, noob :D
Name:
Anonymous2007-03-10 6:37 ID:AlSAPSmu
>>20
No forced indentation in Python expressions, only statements. Any expression can be wrapped with parens, and anything goes within parens; you can use EOL, INDENT and DEDENT liberally.
Name:
Anonymous2007-03-10 11:36 ID:5escpLv+
>>16 Prelude> [ (a, b, c, d) | a <- [1 .. 60], b <- [1 .. 60], c <- [1 .. 60], d <- [1 .. 60], a*b*c*d == 120 ] [(1,1,2,60),(1,1,3,40),(1,1,4,30),(1,1,5,24),(1,1,6,20),(1,1,8,15),(1,1,10,12),(1,2,2,30),(1,2,3,20),(1,2,4,15),(1,2,5,12),(1,2,6,10),(1,3,4,10),(1,3,5,8),(1,4,5,6),(2,2,2,15),(2,2,3,10),(2,2,5,6),(2,3,4,5)]
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy