#!/usr/local/bin/python3

with open('../day6_input.txt') as f:
    lines = [line.rsplit(maxsplit=3) for line in f.read().splitlines()]

# Part one

# Part one
# lights = [[False for i in range(1000)] for j in range(1000)]

# Part two
lights = [[0 for i in range(1000)] for j in range(1000)]

for instruction, start, _, end in lines:
    start_x, start_y = [int(part) for part in start.split(',')]
    end_x, end_y = [int(part) for part in end.split(',')]

    if instruction == 'turn on':
#         func = lambda state: True       # Part one
        func = lambda state: state + 1  # Part two
    elif instruction == 'turn off':
#         func = lambda state: False    # Part one
        func = lambda state: state if state == 0 else state - 1  # Part two
    elif instruction == 'toggle':
#         func = lambda state: not state  # Part one
        func = lambda state: state + 2  # Part two

    for col in range(start_x, end_x + 1):
        row_part = slice(start_y, end_y + 1)
        lights[col][row_part] = map(func, lights[col][row_part])


print(sum(sum(col) for col in lights))

@@ -133,20 +133,8 @@
 )%5D%0A%0A
-# Part one%0A%0A
 # Pa
@@ -470,25 +470,24 @@
 rn on':%0A
-#
         
  func = 
@@ -470,32 +470,33 @@
 rn on':%0A        
+#
  func = lambda s
@@ -508,24 +508,26 @@
  True       
+  
 # Part one%0A 
@@ -561,24 +561,28 @@
  state + 1  
+    
 # Part two%0A 
@@ -616,25 +616,24 @@
 n off':%0A
-#
         
  func = 
@@ -616,32 +616,33 @@
 n off':%0A        
+#
  func = lambda s
@@ -652,24 +652,28 @@
 e: False    
+    
 # Part one%0A 
@@ -785,17 +785,16 @@
 e':%0A
-#
         
  fun
@@ -785,24 +785,25 @@
 e':%0A        
+#
  func = lamb
@@ -823,16 +823,18 @@
  state  
+  
 # Part o
@@ -876,16 +876,20 @@
 te + 2  
+    
 # Part t

clean up more comments