anonymous
  • anonymous
Is anyone interested in posting their code for Exercise 2.6, the NIMS game? I have mine working but I thought it would be nice to see others.
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Of course another quirk in OS is I can't attach a file to a question, but I can to a comment, hence:
1 Attachment
andrew.m.higgs
  • andrew.m.higgs
Yours looks more elegant than mine. :-) I also went on step further and wrap parts in functions and made it that more than two players could play. But that was just for fun.
1 Attachment
anonymous
  • anonymous
Yours is much more robust than mine. And you've used booleans and min, so kudos to you.Thanks for posting.-dan

Looking for something else?

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

More answers

andrew.m.higgs
  • andrew.m.higgs
Pleasure. I believe we learn the most by comparing. That is what makes open source so wonderful. I am going to study your cod because i like the way you worked through the problem.
anonymous
  • anonymous
Study my cod just for the halibut ;-)
andrew.m.higgs
  • andrew.m.higgs
:-) See, peer review works...
anonymous
  • anonymous
Since there is nearly identical code handling each player, I combined them and set a variable to denote the current player.
andrew.m.higgs
  • andrew.m.higgs
What I did as an added bit of work was to create a function called make_move and made it that more then 2 players could play at once.
anonymous
  • anonymous
I tried it with recursion and tried to avoir any exception during game... seems to work fine
1 Attachment
andrew.m.higgs
  • andrew.m.higgs
Hi Fabien, I like your code. Very neat indeed. Only problem is that stack can go negative which means you will never end the game, in certain circumstances. :-)
anonymous
  • anonymous
Made a mistake in my while test... forgot to convert choice to integer and flipped the comparator... Like, I think the problem shouldn't happen again...
1 Attachment
anonymous
  • anonymous
I like the recursive solution from FabienTourne. Anyway, here is mine:
1 Attachment
anonymous
  • anonymous
I'll post the function I used to make the English grammatically correct (with regards to singular vs plural): def plural(counter, word): if word == "stones": if counter == 1: return "stone" else: return "stones" elif word == "are": if counter == 1: return "is" else: return "are" elif word == "remain": if counter == 1: return "remains" else: return "remain" else: return None

Looking for something else?

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