Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. print('''There are n people in the circle. You give the knife to one of them, he stabs person on the right and
  2.    gives the knife to the next person. What will be the number of whoever
  3.    will be left alive?'''
  4.       )
  5.  
  6. pplList = []
  7. numOfPeople = int(input('How many people are there in the circle?'))
  8.  
  9.  
  10. for i in range(1, (numOfPeople + 1)):
  11.     pplList.append(i)
  12. print(pplList)
  13.  
  14. while len(pplList) > 1:
  15.     for i in pplList:
  16.         if i % 2 == 0:
  17.             del pplList[::i]
  18.     print(f'The number of person which survived is {pplList[0]+1}')
  19.     break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement