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
import math | |
def distributionWithNPirates(n): | |
if (n == 1): # Base case | |
return [100] | |
numberOfVotesRequired = int(math.ceil(n / 2.0)) | |
# Pirate n will vote for his proposal regardless | |
numberOfVotesRequired -= 1 | |
distributionIfPirateNKilled = distributionWithNPirates(n - 1) | |
piratesThatGetTheLeastIfPirateNIsKilled = sorted(range(len(distributionIfPirateNKilled)), key=distributionIfPirateNKilled.__getitem__) | |
minimumDistribution = [0] * (n - 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
# Copyright Robert Ketteringham 2013 | |
# Licensed under WTFPL | |
# With help from: | |
# http://www.scipy.org/Cookbook/FIRFilter | |
# http://mpastell.com/2009/11/05/iir-filter-design-with-python-and-scipy/ | |
import numpy as np | |
import matplotlib.pylab as plt | |
from scipy import signal | |
from plot_zplane import zplane |
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
# Copyright Robert Ketteringham 2013 | |
# Licensed under WTFPL | |
# With help from: | |
# http://www.scipy.org/Cookbook/FIRFilter | |
# http://mpastell.com/2009/11/05/iir-filter-design-with-python-and-scipy/ | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy import signal | |
from pylab import unwrap |