My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add MD5 and SHA-256 functions to utils.py

+15 -1
+2 -1
2017/starter.py
··· 6 6 from collections import Counter, deque, namedtuple # NOQA 7 7 from itertools import count, product, permutations, combinations, combinations_with_replacement # NOQA 8 8 9 - from utils import parse_line, mul, factors, memoize, primes, new_table, Point, DIRS, DIRS_4, DIRS_8 # NOQA 9 + from utils import (parse_line, mul, factors, memoize, primes, new_table, md5, sha256 # NOQA 10 + Point, DIRS, DIRS_4, DIRS_8) # NOQA 10 11 11 12 # Itertools Functions: 12 13 # product('ABCD', repeat=2) AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD
+13
2017/utils.py
··· 1 1 import re 2 2 import math 3 + import hashlib 3 4 import operator 4 5 from functools import total_ordering 5 6 ··· 77 78 def primes(n): 78 79 """Return a list of primes from [2, n)""" 79 80 return list(_eratosthenes(n)) 81 + 82 + 83 + def md5(msg): 84 + m = hashlib.md5() 85 + m.update(msg) 86 + return m.hexdigest() 87 + 88 + 89 + def sha256(msg): 90 + s = hashlib.sha256() 91 + s.update(msg) 92 + return s.hexdigest() 80 93 81 94 82 95 @total_ordering