could use some help with this problem! I've been working on it for days but cant seem to get it right !
Ben Bacarisse
ben.usenet at bsb.me.uk
Tue Feb 20 09:10:07 EST 2018
Marc Cohen <mcohenact at gmail.com> writes:
> USING PYTHON 2:
Why is that?
> Write a program to play this game. This may seem tricky, so break it
> down into parts. Like many programs, we have to use nested loops (one
> loop inside another). In the outermost loop, we want to keep playing
> until we are out of stones.
You almost never /have/ to use nested loops. Has the course got this
far without introducing the idea of a function?
<snip>
> So, the basic outline of the program should be something like this:
>
> totalStones = 100
>
> maxStones = 5
maxTake or maxMove might be a more helpful name.
> pile = TOTAL # all stones are in the pile to start
>
> while [pile is not empty]:
>
> while [player 1's answer is not valid]:
>
> [ask player 1]
>
> [execute player1’s move]
>
> Do the same for player 2…. (this can be achieved by a for loop)
Is the idea for the program to play an optimal strategy for player 2, or
is the program simply doing the housekeeping -- verifying moves and
tracing the pile of stones?
<snip>
--
Ben.
More information about the Python-list
mailing list