[Tutor] Python code trouble!
Asokan Pichai
pasokan at talentsprint.com
Tue Nov 22 11:15:28 CET 2011
Okay!
I wrote some code. It is below so that you can avoid scrolling down and
seeing it if you do not want to see any code!
HTH
Asokan
people = list(" ABCDEFGHIJKLMN")
COUNT = len(people)
remove = 3
SPACE = ' '
def survivorCount(a):
return len(a) - a.count(SPACE)
pos = 0
men = 0
while survivorCount(people) != 1:
if people[pos] != SPACE:
men += 1
if men % remove == 0:
print "removed", people[pos], "at", pos
people[pos] = SPACE
pos = (pos + 1) % COUNT
print ''.join(people).strip()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111122/1915812f/attachment.html>
More information about the Tutor
mailing list