A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Hey I'm on Pset2 I kind of have it figured out but mine code only works for big numbers. When i use 15 as my number of nuggets i get no solution but when i use 56 or 58 i get correct answers. Here is my code please help as much as you can. http://pastebin.com/tiNdLAiM

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i tested it with 18 as my number and it worked so I don't know why 15 won't work

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I figured it out here is my completed version. http://pastebin.com/N7gS2uvM I added lines 6 and 8. If you have questions on what i did feel free to ask.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    How could you get this to print the best possible solution?

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    This was for problem 1 i haven't figured out problem 3 yet.

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    your program for the first problem only prints the worst solution. I reworked it so that it prints all possible solutions. Now i just need to get the best one. I'm having trouble figuring out what kind of statement will help me accomplish that

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Why do you need all possible? You only need one to know whether or not its a possible combination.

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    If you want a script that prints all possible i have one but I don't see why you would need it.

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it helped me understand the logic for part 3 a little easier thats all

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yes i have both also

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    O ok

  11. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    when it prints all the solutions the last one is always the best. I just need to find a way to only print that one

  12. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I don't know how to only print last one but what I'm wondering is why you only want last one. I don't see what it changes last or first as long as there is a solution.

  13. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    trying to make it more efficient

  14. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    O I see what your doing your thinking if it was an actual mcdonalds what would be the best way to arrange it. am i correct?

  15. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    exactly

  16. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok cool I probably should be doing that too but right now I'm more focused on learning the syntax of the language and later on when I know more about the language I will be able to apply it in any way I want.

  17. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Probably not the best logic but it makes sense in my head haha.

  18. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Probably not the best logic but it makes sense in my head haha.

  19. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hey I was laying down going to sleep and was thinking what if you change the order of the solutions like you said my worst solution comes first. Well in my code i solve for large first. What if you solve for the small first then medium and then large then your solutions will be in opposite order. At least that makes sense to me. I don't know whether or not it will work and I'm going to bed so I don't have time to test it but if you really want the best possible solution it's worth a try. Let me know if this works or if it helped you find the solution basically just keep me updated.

  20. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thats all it needed.

  21. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Sweet!

  22. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.