-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
61 lines (46 loc) · 1.09 KB
/
test.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'play' function below.
#
# The function is expected to return an INTEGER.
# The function accepts 2D_INTEGER_ARRAY arr as parameter.
#
def play(arr):
tom=0
jerry=0
c=0
done=[]
max = -1
maxc= -1
while(len(done)!=len(arr)):
print(max,maxc,tom,jerry,done)
max = -1
maxc = -1
for i in range(0,len(arr)):
if(i not in done):
for j in range(0,len(arr[0])):
if(arr[i][j]>=max):
max=arr[i][j]
maxc=i
if(c%2==0):
tom+=max
else:
jerry+=max
c+=1
done+=[maxc]
return abs(tom-jerry)
if __name__ == '__main__':
fptr = open(os.environ['input001.txt'], 'w')
arr_rows = int(input().strip())
arr_columns = int(input().strip())
arr = []
for _ in range(arr_rows):
arr.append(list(map(int, input().rstrip().split())))
result = play(arr)
fptr.write(str(result) + '\n')
fptr.close()