Hello All,

I am learning python and hence was writing code for school assignments I
could find online. I wrote my solution for this problem below. Please find
it attached.

I would like someone to review and give me comments on it. Basically
improvements/ comments to make it more efficient

problem.py has print statements in them. problem_clean is cleaner version
of the same.

Thanks,

G


Two players take turns flipping a fair coin. The game ends when the same
outcome occurs on three flips in a row. Whichever player flipped the coin
last, wins. For example:

Player 1 flips H
Player 2 flips T
Player 1 flips T
Player 2 flips H
Player 1 flips H
Player 2 flips H <<< player 2 wins

or

Player 1 flips T
Player 2 flips T
Player 1 flips T <<< player 1 wins

or

Player 1 flips H
Player 2 flips H
Player 1 flips T
Player 2 flips H
Player 1 flips T
Player 2 flips H
Player 1 flips T
Player 2 flips T
Player 1 flips H
Player 2 flips H
Player 1 flips H <<< player 1 wins

Attachment: problem_clean.py
Description: Binary data

Attachment: problem.py
Description: Binary data

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to