Hello, can someone help me with my code about Ps2 Diophantine equations? I am stuck at the problem 4. When I run my code, it just keeps going on and on and never gives me any output. I have to press ctrl+c to stop. Here is my code: http://bpaste.net/show/53890/ I cannot figure out what is wrong. Can somebody help me with my code? Thank you.
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
the code is ok - try putting a print(a,b,c,n) before the break statement. the break only exits the bottom loop, for c, but continues for a and for b. test it with n in range(10), for example, and x=1, y=2, z=3. you may want to print solutions rather than bestSoFar, but play with it.
Your code is probably running just fine. The trouble is that with 4 nested loops, each going up to 200, you're doing somewhere in the area of 200**4 iterations. That takes a while, quite possibly hours, to run. This is something to keep in mind when your designing your algorithm.
Thank you, guys. Yes, my code is, indeed, running fine. Can I ask whether there is a way of break out all nested loops? I can only think of using this 4 nested loops to solve this problem set. Is there any other efficient way? Some hints?