Unable to load image
Reported by:

rDrama Advent of Code Day 1: Warm up

I hope this fine morning finds you well, saars.

The word of the day is collections.Counter

The rdrama leaderboard invite code is 632268-30587026

I created the ping group: !AOC, I'm sure it will be useful offseason too.

Charts! https://github.com/jeroenheijmans/advent-of-code-charts

19
Jump in the discussion.

No email address required.

@ogsambone heard you like lambdas

with open('input.txt', 'r') as file:
    f = file.read()

print(sum(abs(a - b) for a, b in zip(*map(lambda x: sorted(map(int, x)), zip(*(x.split() for x in f.strip().split('\n')))))))

print((lambda a, b: sum(y*b.count(y) for y in a))(*list(map(lambda x: list(map(int, x)), zip(*(x.split() for x in f.strip().split('\n')))))))
Jump in the discussion.

No email address required.

Lmao, I was wondering when someone would do some crazy one-liners with zip and map. :pepehacker:

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.