Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

AppylPye Group Title

Exercise 2.6 – The game of Nims/Stones Here's a solution, but it departs from the "basic outline" prescribed in the 6.189 Homework 2 handout by handling both players in a single loop. When I tried to use two separate loops, it got messy because there was a lot of duplication of code, including watching for the end game condition, ready to terminate execution from either loop after all the stones had been taken. Does anyone have a solution that uses two loops without a lot of repetition of code? http://ideone.com/kLQ5Zf The solution is written for Python 3..

  • one year ago
  • one year ago

  • This Question is Closed
  1. cb12 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I think that if you are going to use a loop for each player, you are going to repeat code. However, I think that it can still be easy to read (though I know I should have commented my solution). You can view my Python 2.7 solution here: http://pastebin.com/sW0SrkdL. I had another version where I used a function to handle the players' turns, but I can't find it.

    • one year ago
  2. AppylPye Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks. If you find your other version, please post that one here as well. It would be interesting to look at the variety of solutions that people have developed.

    • one year ago
    • Attachments:

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