Hey there little guy

heck
Uhh, where the HECK is my solutionerino?
-You, with a smaller code length AND penis length than I
smolheck/smolheck-day01.py
smolheck/smolheck-day01.py
win = 3 # window
    nums = [ int(line) for line in open('input').readlines() ]
    res = [ sum(nums[i+1:i+1+win]) > sum(nums[i:i+win]) for i in range(len(nums)) ]
    print(res.count(True))
    
smolheck/smolheck_day01.py
smolheck/smolheck_day01.py
#!/usr/bin/python
    
    nums = [ int(line) for line in open('input').readlines() ]
    def solve(n):
        return sum(y > x for x,y in zip(nums, nums[n:]))
    
    print("Part 1:", solve(1))
    print("Part 2:", solve(3))
    
smolheck/smolheck_day02.py
smolheck/smolheck_day02.py
#!/usr/bin/python
    
    course = [ [c,int(x)] for line in open('input').read().splitlines()
               for c,x in [line.split()] ]
    
    def solve(part):
        hor = 0
        depth = 0
        aim = 0
        for c,x in course:
            if c[0] == 'f':
                hor += x
                if part == 2:
                    aim += depth\*x
            elif c[0] == 'u':
                depth -= x
            elif c[0] == 'd':
                depth += x
        if part == 1:
            return hor\*depth
        else:
            return hor\*aim
    
    print("Part 1:", solve(1))
    print("Part 2:", solve(2))
    

Tags: