-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFarmerWolfGoatCabbage.py
More file actions
30 lines (26 loc) · 909 Bytes
/
Copy pathFarmerWolfGoatCabbage.py
File metadata and controls
30 lines (26 loc) · 909 Bytes
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
my_list = [[0, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 0],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 1, 0, 1],
[0, 1, 1, 0],
[0, 1, 1, 1],
[1, 0, 0, 0],
[1, 0, 0, 1],
[1, 0, 1, 0],
[1, 0, 1, 1],
[1, 1, 0, 0],
[1, 1, 0, 1],
[1, 1, 1, 0],
[1, 1, 1, 1]]
to_remove = [] # Create a list to store indices of elements to remove
for i in range(len(my_list)):
if (my_list[i][2] == my_list[i][3]) and (my_list[i][2] != my_list[i][0]):
to_remove.append(i)
if (my_list[i][1] == my_list[i][2]) and (my_list[i][2] != my_list[i][0]):
to_remove.append(i)
# Remove elements from the original list using indices stored in to_remove list
for index in sorted(to_remove, reverse=True):
my_list.pop(index)
print(my_list)