[ Launch: Helping Dave - new ] 8035870 by Radcliffe
This file contains hidden or 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 collections import Counter | |
def sanity_check(grid): | |
if not(isinstance(grid,list) | |
and len(grid) == 9 | |
and all(isinstance(row, list) | |
and len(row) == 9 | |
for row in grid) | |
and all(isinstance(elt, int) | |
and 0 <= elt <= 9 |
This file contains hidden or 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/python | |
# 5-line fuzzer below is from Charlie Miller's | |
# "Babysitting an Army of Monkeys" | |
from os import listdir | |
from os.path import isfile, join | |
mypath = '/users/david/documents/python/pdf/' | |
file_list = [ mypath+f for f in listdir(mypath) if isfile(join(mypath,f)) ] |
This file contains hidden or 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 2.7 program to check whether two integer powers are equal, | |
# WITHOUT computing the powers. | |
# | |
# Author: David Radcliffe, 1 December 2013. | |
ALLOW_ZERO_TO_ZERO = True | |
# If True, assume that 0 to the 0 is 1. | |
# If False, assume that 0 to the 0 is undefined. | |
# Return the sign of a^b. There are four possible results |
This file contains hidden or 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
# Solution to a problem posted by Deomani Sharma Ramsurrun | |
# David Radcliffe 11 Dec 2013 | |
# This code is in the public domain | |
########################################################### | |
import fractions | |
# Generate all non-negative integer solutions to the system | |
# ab + ac + ad = 6 | |
# ab + bc + bd = 9 |
This file contains hidden or 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/python | |
# Author: David Radcliffe ([email protected]) | |
# Date: 20 December 2013 | |
# This code is in the public domain. | |
# Problem: Given a square 5x5 grid of points, find five circles that together pass through all 25 points. | |
# There are 21 essentially different solutions. Two solutions are considered the same if they differ only | |
# by a rotation or reflection. This script finds all of these solutions. | |
# The solutions are rendered graphically at http://www.gotmath.com/doc/fivecircles.html |
[ Launch: Covering a grid with circles ] 8071295 by Radcliffe
[ Launch: Tributary inlet ] 9024863 by Radcliffe
This file contains hidden or 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 python | |
# | |
# This Python 2.7 script solves the following probability problem: | |
# If 20 distinct positive integers are chosen from the range 1 - 80 | |
# (without replacement) what is the probability that their sum is 810? | |
# Source: Kim Zafra, http://lnkd.in/bmg4AR5 | |
# Remarks: |
This file contains hidden or 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 python | |
# | |
# List the numbers n such that the digits of the square of n | |
# can be rearranged to form exactly two other squares. | |
# For example, 13 belongs to list because 13*13 = 169, and | |
# the digits of 169 can be rearranged to form the squares 196 | |
# (= 14*14) and 961 (= 31*31); but no other squares can be formed | |
# by rearranging the digits of 169. | |
# | |
# Inspired by a question of James Tanton (@jamestanton on Twitter). |
OlderNewer