Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

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

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
See more answers at brainly.com
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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

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

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question