On 11/27/2011 7:43 PM, Guess?!? wrote:
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:
Here's my version of a simple compact program. import random N = 10 tosses = ''.join(random.choice("HT") for i in range (N)) w = min(tosses.find("TTT") % N + 1,tosses.find("HHH") % N + 1) if w == N: print 'no winner' else: print tosses[:w+2], 'player %s wins.' %((w % 2) + 1,) -- Bob Gailer 919-636-4239 Chapel Hill NC _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor