Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. from random import randrange as r
  2.  
  3. doors = {}
  4.  
  5. for x in range(1,101): #This part creates doors that are either closed or open.
  6. doors["door00%s" %x] = "closed"
  7.  
  8. def toogle_doors(x): #This part toogles (if open(1), close(2); if closed(2), open(1)) all the doors with number which can be divided to x
  9. for k,v in doors.items():
  10. number = int((str(k))[-3] + (str(k))[-2] + (str(k))[-1])
  11. if number % x == 0:
  12. if v == "closed":
  13. doors[k] = "open"
  14. else:
  15. doors[k] = "closed"
  16.  
  17. for i in range(1,101): #Starts toogling doors from ones that can divided 1 and contuniues untill 100
  18. toogle_doors(i)
  19.  
  20. for k,v in sorted(doors.items()): #Prints the current state of all the doors
  21. print (k, v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement