Writing a Nim game in ruby

wondering does anyone know how to help with this problem

n and t should be constants in your program, but give them better names
like INITIAL_NUM_MATCHES and MAX_ALLOWED_TO_TAKE. You may assume that
the user plays first and the computer second, and so on.

When n=k*(t+1)+1, for some constant k, your program should always win.
When this is not the case, your program should take a random number of
matches from the pile. If the user makes an error on their turn, your
program should play correctly and win the game.

Your program should have a class called Nim that manages the game
itself. Your main program can manage user input, or you can put this
into another class if you wish.

A good approach to this assignment is to assume that the initial number
of matches is 21 (n=21) and that the maximum number of matches that may
be taken on a turn is 4 (t=4). When you have this problem solved and you
are satisfied your program is correct, extend your program to handle the
more general case where n and t can have other values.

Uhh, what kind of help are you looking for? Or did you just want
someone to do your homework for you?

Sorry for the snark, but it’s true - you’re not going to learn Ruby if
you just ask other people to do it for you.

Very true sir but I was short on time and if someone had already done it
would have saved me the effort. Hence it would have helped me.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs