Pages

Monday 7 September 2015

CodeEval - Find the highest score - Easy

import sys

test_cases = open(sys.argv[1], 'r')
for test in test_cases:
    rows=test.split(" | ")
    maxVals=rows[0].split(" ")
    for i in range(1,len(rows)):
        cols=rows[i].split()
        for j in range(len(cols)):
            if int(maxVals[j]) < int(cols[j]):
                maxVals[j] = cols[j]
    sol=""
    for i in range(len(maxVals)):
        if i > 0 :
            sol += " "
        sol+=maxVals[i]
    print sol

test_cases.close()

No comments:

Post a Comment