Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """ this code refer to this article: http://www.codeproject.com/Articles/436455/Jail-Break-Quiz
- Points of Interest
- - just show a Python perspective, and how improve Legibility;
- """
- MAX = 101;
- def print_doors(door_is_open):
- output = ''
- for value in door_is_open:
- if(value):
- output +='o'
- else:
- output +='c'
- print '%s - %s open doors' % (output,output.count('o'))
- if __name__ == "__main__":
- array = range(1,101)
- door_is_open = [False for door in array]
- for i in array:
- for j in range(i,101,i):
- door_is_open[j-1] = not door_is_open[j-1]
- print_doors(door_is_open)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement