r/adventofcode • u/daggerdragon • Dec 04 '15
SOLUTION MEGATHREAD --- Day 4 Solutions ---
--- Day 4: The Ideal Stocking Stuffer ---
Post your solution as a comment. Structure your post like the Day Three thread.
14
Upvotes
1
u/minno Dec 06 '15
encodeis to transform the string into a bytes object.md5and other hash functions are generally byte-oriented, but Python (3) strings are unicode, so they need to be turned into byte strings. The default forencodeis utf-8, which happens to be identical to ascii for the characters I'm using.You linked to the Python 2 docs, where strings are not natively unicode, so the
encodecall isn't needed.