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
|
## Example 1
## nRow = 2
## nCol = 3
## arrLoc = [[0, 1], [1, 1]]
## Example 2
## nRow = 2
## nCol = 2
## arrLoc = [[1, 1], [0, 0]]
## Example 3
## nRow = 3
## nCol = 3
## arrLoc = [[0, 0], [1, 2], [2, 1]]
## Example 4
## nRow = 1
## nCol = 5
## arrLoc = [[0, 2], [0, 4]]
## Example 5
nRow = 4
nCol = 2
arrLoc = [[1, 0], [3, 1], [2, 0], [0, 1]]
arrList = [[0 for _ in range(nCol)] for _ in range(nRow)]
for arrLoop in arrLoc:
nRowIndx = arrLoop[0]
nColIndx = arrLoop[1]
for nIndx in range(nCol):
arrList[nRowIndx][nIndx] = arrList[nRowIndx][nIndx] + 1
for nIndx in range(nRow):
arrList[nIndx][nColIndx] = arrList[nIndx][nColIndx] + 1
nOddCount = sum([len([nElem for nElem in arrLoop if nElem % 2 == 1]) for arrLoop in arrList])
print (nOddCount)
|