mirror of
https://github.com/Xevion/advent-of-code.git
synced 2025-12-07 11:14:21 -06:00
day 1 and 2
This commit is contained in:
13
2018/day-2/python/main.py
Normal file
13
2018/day-2/python/main.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import os, sys, pyperclip
|
||||
|
||||
def count(string):
|
||||
return [string.count(k) for k in list(set(string))]
|
||||
|
||||
path = os.path.join(sys.path[0], '..', 'input')
|
||||
data = open(path, 'r').read().split()
|
||||
data = sum(map(count, data), [])
|
||||
two, three = data.count(2), data.count(3)
|
||||
|
||||
answer = two * three
|
||||
print("{} x {} = {}".format(two, three, answer))
|
||||
pyperclip.copy(answer)
|
||||
Reference in New Issue
Block a user