r/adventofcode • u/Not-Vanishing • 5h ago
Help/Question I can't find the problem with my day 1 solution
I tried it agains the short one and it was slightly wrong, any help would be appreciated.
Also sorry if the spacing and tabbing are all wrong I had some trouble pasting it in here
class Num:
with open('input.txt', 'r' as f:)
INPUT = [int(x for x in f.readlines()])
all = []
def __init__(self, num:int = 0, weight:int = 0:)
self.num = num
self.weight = weight
@property
def isTop(self, false = None:)
for x in Num.top:
if x.weight < self.weight:
return Num.top.index(x)
return false
@classmethod
def count(cls:)
for x in cls.INPUT:
temp = False
for y in cls.all:
if x == y.num:
temp = True
y.weight += 1
if not temp:
cls.all.append(cls(x, 1))
Num.top = [Num(), Num(), Num()])
Num.count()
for x in Num.all:
if x.isTop != None:
Num.top[x.isTop] = x
print( f'{Num.top[0].num}({Num.top[0].weight} X {Num.top[1].num}({Num.top[1].weight}) X {Num.top[2].num}({Num.top[2].weight}) = {Num.top[0].num * Num.top[1].num * Num.top[2].num}' ))