diff --git a/day08/sol2b.py b/day08/sol2b.py new file mode 100644 index 0000000..cab0b94 --- /dev/null +++ b/day08/sol2b.py @@ -0,0 +1,29 @@ +data = [] +for line in open("input"): + data.append(list(map(int, line.strip()))) + +def count(top, ii, jj): + n = 0 + for i in ii: + for j in jj: + n += 1 + if data[i][j] >= top: + return n + return n + +scores = [] +for ii in range(len(data)): + for jj in range(len(data[ii])): + top = data[ii][jj] + a = count(top, [ii], range(jj+1, len(data[ii]))) + b = count(top, [ii], reversed(range(0, jj))) + c = count(top, range(ii+1, len(data)), [jj]) + d = count(top, reversed(range(0, ii)), [jj]) + + #print(ii,jj,a,b,c,d) + score = a*b*c*d + scores.append(score) + +#print(visible) +#print(sum(sum(x) for x in visible)) +print(max(scores))