Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
Hello! I just completed problem 3 on problem set 2. Can you guys look at my code to see if any areas to improvement? or your code to compare?
n=1;Diophantine=();check=0
while (n<70):
a=0;b=0;c=0;ans=()
while (6*a+9*b+20*c<n):
for a in range(0,100):
for b in range(0,100):
for c in range(0,100):
if 6*a+9*b+20*c == n:
ans=ans+(n,)
if len(ans)==0:
Diophantine=Diophantine+(n,)
check=0
else:check+=1
if check==6:
print Diophantine[1]
n+=1
 one year ago
 one year ago
Hello! I just completed problem 3 on problem set 2. Can you guys look at my code to see if any areas to improvement? or your code to compare? n=1;Diophantine=();check=0 while (n<70): a=0;b=0;c=0;ans=() while (6*a+9*b+20*c<n): for a in range(0,100): for b in range(0,100): for c in range(0,100): if 6*a+9*b+20*c == n: ans=ans+(n,) if len(ans)==0: Diophantine=Diophantine+(n,) check=0 else:check+=1 if check==6: print Diophantine[1] n+=1
 one year ago
 one year ago

This Question is Closed

bwCABest ResponseYou've already chosen the best response.0
please use a code pasting site:  http://dpaste.com  http://pastebin.com  http://www.repl.it/  http://pastie.org  http://codepad.org  http://ideone.com paste your code there and post the link here. select Python syntax highlighting when u paste.
 one year ago

LoveMathFermatBest ResponseYou've already chosen the best response.0
Thank you bwCA! here is the link: http://dpaste.com/826170/
 one year ago

bwCABest ResponseYou've already chosen the best response.0
i limited my for loop ranges to say n / 6 + 1 or 20 / 6 + 1. and added break statements after each for statement to break if the equation evaluated to > n
 one year ago

snarkBest ResponseYou've already chosen the best response.1
again, it's cool... might as well allow user to enter constants, and print entire solution you can see how much the break statements speed it up: try commenting them out http://dpaste.com/826177/ of course, if you allow negative constants 5a + 6b c = 17 the breaks will miss alot.
 one year ago

LoveMathFermatBest ResponseYou've already chosen the best response.0
Thank you !!! Guys! I really appreciate your help!
 one year ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.