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
# Dynamic programming solution to the ugly numbers problem. | |
# Author: Jon Brandvein | |
# See problem at: https://www.codeeval.com/public_sc/42/ | |
from itertools import chain | |
from functools import lru_cache | |
uglyprimes = [2, 3, 5, 7] | |
def ugly(n): |
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
""" | |
pilwrapper.py: A simple wrapper around the Python Imaging Library, | |
or its replacement, Pillow. | |
Copyright (c) 2012-2014 Jon Brandvein | |
Freely available under the MIT License (http://opensource.org/licenses/MIT). | |
""" | |
__version__ = '0.1.0' | |
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 pypandoc import convert | |
from pandocfilters import walk | |
import json | |
def delink(key, value, format, meta): | |
if key == 'Link': | |
text, _ = value | |
return text | |
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
# Python implementation of Toads and Frogs. | |
# See http://en.wikipedia.org/wiki/Toads_and_Frogs_(game) | |
# Author: Jon Brandvein | |
# Toads move right, frogs move left. Each piece can jump over | |
# the opposite kind of piece. | |
p1_rules = [ | |
('t.', '.t'), | |
('tf.', '.ft'), |
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
% Program to find all winning plays of Toads and Frogs. | |
% See http://en.wikipedia.org/wiki/Toads_and_Frogs_(game) | |
% Author: Jon Brandvein | |
% Changes: | |
% 05/02/13 - eliminate list processing helper rules in favor of | |
% a simpler append-based definition of player moves | |
% (thanks to David Warren) | |
:- import select/3, append/3 from basics. |