-
Notifications
You must be signed in to change notification settings - Fork 0
/
prec2.py
45 lines (34 loc) · 789 Bytes
/
prec2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
#!/usr/bin/env python
# 1 is on and 0 is off
import sys
#print sys.argv
# list1 = []
'''def try1():
list1 = []
for i in range(num_lights):
list1.append(1)
return'''
num_lights = int(sys.argv[-1])
print "Number of lights = ", num_lights
list1 = [1]*num_lights
print list1
def process_lights():
for n in range(2, num_lights+1):
for i in range(len(list1)):
if (i+1) % n == 0:
if list1[i] == 0:
list1[i] = 1
elif list1[i] == 1:
list1[i] = 0
return list1
list1 = process_lights()
print list1
for l in range(len(list1)):
list2 = []
if list1[l] == 1:
print 'a'
print l
list2.append(l+1)
print list2
# Why no list2?