This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Functional solution to https://adventofcode.com/2016/day/1 part 1 | |
# with reduce() and lambda vs no lambda | |
# Mark Jenkins <mark@markjenkins.ca> | |
from functools import reduce | |
MOVEMENTS = ((0,1), (1,0), (0,-1), (-1,0)) | |
DIRECTION_CHANGES = {"R": 1, "L": -1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# solution to https://adventofcode.com/2016/day/1 part 2 | |
# in a functional style with python 3.3+ enhanced accumulate() and dropwhile() | |
# Mark Jenkins <mark@markjenkins.ca> | |
from itertools import accumulate, dropwhile, chain | |
MOVEMENTS = ((0,1), (1,0), (0,-1), (-1,0)) | |
DIRECTION_CHANGES = {"R": 1, "L": -1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Solution to http://adventofcode.com/2016/day/2 part 1 | |
# using reduce and accumulate for awesome functional programing style points | |
# Mark Jenkins <mark@markjenkins.ca> | |
from sys import stdin | |
from functools import reduce | |
from itertools import chain, accumulate, islice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# functional solution to http://adventofcode.com/2016/day/3 part 1 | |
# Mark Jenkins <mark@markjenkins.ca> | |
from sys import stdin | |
def possible_triangle(args): | |
assert(len(args)==3) | |
sum_args = sum(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Solution to http://adventofcode.com/2016/day/4 part 1 | |
# Mark Jenkins <mark@markjenkins.ca> | |
from sys import stdin | |
from collections import Counter | |
from itertools import islice | |
CHECKSUM_SIZE = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
def map( func, iterable): | |
def f(a, b): | |
return a + [func(b)] | |
return reduce( f, iterable, [] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Voter code yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY= votes for Pirates | |
non interactively | |
echo -e "yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY=\nPirates" | python3 hmac_vote.py | |
interactively | |
python3 hmac_vote.py | |
What's your code? > yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY= | |
Your code is: | |
yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<a href="https://markjenkins.ca">Return to markjenkins.ca</a> | |
</p> | |
<p> | |
This contact form submits to my | |
<a href="mailto:mark@markjenkins.ca">mark@markjenkins.ca</a> email address. | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elected by acclamation | |
Michael Kozakewich | |
Kyle Martin | |
Edwin Amsler | |
Thor Robinson | |
Pietra Shirley |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abandon | |
ability | |
able | |
about | |
above | |
absent | |
absorb | |
abstract | |
absurd | |
abuse |