Untitled

 avatar
unknown
plain_text
2 years ago
1.3 kB
2
Indexable
input = open("input.txt", encoding="utf-8")

parsedInput = []
array2d = []
array2d2 = []
i = 0
j = 0
highestTree = 0

for line in input:
    parsedInput.append(line.rstrip())

for line in parsedInput:
    arr = []
    for char in line:
        arr.append(int(char))
    array2d.insert(i, arr)
    i += 1

for l in range(len(array2d)):
    array2d2.append([])
    for x in range(len(array2d)):
        array2d2[l].append(array2d[x][l])

def treeCheck(arrInput):
    score = 0
    for i in range(len(arrInput)):
        if arrInput[i][0] != 0:
            highestTree = arrInput[i][0]
            score += 1
        else:
            highestTree = 0

        for tree in arrInput[i]:
            if tree == highestTree:
                continue
            elif tree > highestTree:
                highestTree = tree
                score += 1

    for i in range(len(arrInput)):
        arrInput[i].reverse()
        if arrInput[i][0] != 0:
            highestTree = arrInput[i][0]
            score += 1
        else:
            highestTree = 0

        for tree in arrInput[i]:
            if tree == highestTree:
                continue
            elif tree > highestTree:
                highestTree = tree
                score += 1
                
    print(score)

treeCheck(array2d)
treeCheck(array2d2)
Editor is loading...