Skip to content

Instantly share code, notes, and snippets.

M Hickford hickford

Block or report user

Report or block hickford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# -*- coding: utf-8 -*-
# I have in my pocket the following British coins: one £2, two £1, two 50p, three 20p, one 10p, two 5p, two 2p and two 1p. I wish to buy a copy of today's paper at a cost of £1.70.
# What is the maximum number of coins I can use to pay for the paper? With the restriction that I pay in a reasonable manner (e.g. I could give exactly £1.70 or an amount greater than that but without giving extraneous coins: e.g. giving the seller all the coins would not be acceptable, but giving him one £1 an two 50ps and expecting 30p in change is OK). The reasonable manner is simply: if I give the seller a set of coins he should not be able to return any to me without the sum of the remaining coins dropping below £1.70.
from collections import Counter, OrderedDict
def solve_exact(coins, P, f=len):
hickford /
Created May 7, 2013
Attempted solution to Google Code Jam's Osmos problem. Turned out to be incorrect.
# Armin is playing Osmos, a physics-based puzzle game developed by Hemisphere Games. In this game, he plays a "mote", moving around and absorbing smaller motes.
# lemma if we delete a mote size x, we should delete all motes greater than size x
import fileinput
f = fileinput.input()
T = int(f.readline())
hickford / Co.key
Created Oct 5, 2015
FreeDOS ships with the Colemak keyboard layout (to use, type "keyb co"). This file extracted from FREEDOS\PACKAGES\BASE\KEYBX\source\keydos\Co.key
View Co.key
18S 33/f 33/F 33/#6 33/#0 33/#0
19S 25/p 25/P 25/#16 25/#0 25/#0
20S 34/g 34/G 34/#7 34/#0 34/#0
21S 36/j 36/J 36/#10 36/#0 36/#0
22S 38/l 38/L 38/#12 38/#0 38/#0
23S 22/u 22/U 22/#21 22/#0 22/#0
24S 21/y 21/Y 21/#25 21/#0 21/#0
25S 39/#59 39/: 39/#0 39/#0 39/#0
31S 19/r 19/R 19/#18 19/#0 19/#0
hickford / reactive-where.cs
Created May 28, 2012
Reactive Extension's Where method reimplemented
View reactive-where.cs
public static class ObservableExtensions
public static IObservable<TSource> Where<TSource> (this IObservable<TSource> source, Func<TSource,bool> predicate)
if (source == null)
throw new ArgumentNullException("source");
if (predicate == null)
hickford / foreach-final-item.cs
Created May 24, 2012
C# foreach loop with different action for final item
View foreach-final-item.cs
public static class EnumerableExtensions
/// <summary>
/// Perform an action on each element of an IEnumerable<T>, optionally specifying a different action for the final item.
/// </summary>
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action, Action<T> finalAction=null)
if (source == null)
throw new ArgumentNullException("source");
#!/usr/bin/env coffee
history = {}
plans = {}
spew = () -> console.log(new Date)
setInterval spew, 1000
hickford / example.cs
Created Mar 8, 2012
Python's timedelta for .NET and C#
View example.cs
hickford / gist:792036
Created Jan 23, 2011
test if brackets in string are well-nested
View gist:792036
def f(word):
open = 0
for x in word:
if x == "(":
open += 1
elif x == ")":
open += -1
if open < 0:
return False
return open==0
hickford /
Created Jul 7, 2015
Project Euler problem 500
# Project Euler problem 500
"""The number of divisors of 120 is 16.
In fact 120 is the smallest number having 16 divisors.
Find the smallest number with 2**500500 divisors.
Give your answer modulo 500500507."""
from codejamhelpers import primes
import heapq
hickford /
Last active Aug 29, 2015
How to make 21 from the numbers 1,5,6,7?
import operator
import itertools
from fractions import Fraction
operations = dict()
operations['+'] = operator.add
operations['-'] = operator.sub
operations['/'] = operator.truediv
operations['*'] = operator.mul
You can’t perform that action at this time.