Skip to content

Instantly share code, notes, and snippets.

View hayd's full-sized avatar
😎
chillin'

Andy Hayden hayd

😎
chillin'
View GitHub Profile
@hayd
hayd / cs258ps3sudokuCheckAndFill.py
Created July 12, 2012 13:07
Sudoku checker - checks whether a sudoku grid is allowable, or completable (and if so fills it in)
def check_sudoku(grid):
'''If grid is a valid sudoku board, so far filled-in correctly: returns True
else if grid is a valid sudoku board but has been filled-in incorrectly: returns False
else: returns None
Note: returning True does not imply there is a solution for grid, see solve_sudoku.
'''
def sanity_check():
'''If grid is of the sudoku board format: returns True
else: returns None
@hayd
hayd / sudukoObject.py
Created July 13, 2012 16:48
Sudoku object - with hints
#Note this requires the function solve_sudoku.
def Sudoku(grid):
def __init__(self):
self.grid = grid
self.solution = solve_sudoku(self.grid)
self.hints = self.get_hints()
def solvable(self):
return bool(self.solution)
@hayd
hayd / checkSudoku.js
Created July 13, 2012 22:48
Sudoku checker (JS)- checks whether a sudoku grid is allowable, or completable (and if so fills it in)
//This is a conversion from a Python file to JavaScript (from https://gist.github.com/3097993)
//It's in progress (by which I mean: completely untest).
function set(list){
/*
* returns list with no repeated entries
*/
var set_list = [];
for (var element in list){
if (!(element in set_list)){
@hayd
hayd / SuperSudoku.js
Created July 15, 2012 16:34
Super Sudoku
/*
* Solve Every Sudoku Puzzle
*
* See http://norvig.com/sudoku.html
*
* Throughout this program we have:
* r is a row, e.g. 'A'
* c is a column, e.g. '3'
* s is a square, e.g. 'A3'
* d is a digit, e.g. '9'
@hayd
hayd / scope_test.py
Created July 19, 2012 11:55
grabbing f's environment from within g
def f():
a = 2
b = 1
def g():
#a = 3
b = 2
c = 1
print dict(globals(), **locals()) #prints a=1, but we want a=2 (from f)
g()
a = 1
@hayd
hayd / EnvironmentHierarchy.py
Created July 19, 2012 14:07
Environment hierarchy - g can see f's variable a
def f():
a=1
def g():
print a
g()
f()
@hayd
hayd / pdf_fuzz.py
Created July 20, 2012 09:15 — forked from kedarbellare/pdf_fuzz.py
PDF Fuzzer
file_list = ["10.1.1.111.1781.pdf", "10.1.1.111.5264.pdf", "10.1.1.39.1596.pdf", "10.1.1.41.8589.pdf", "10.1.1.42.5619.pdf"]
apps_list = [
"/Applications/Adobe Reader 9/Adobe Reader.app/Contents/MacOS/AdobeReader",
"/Applications/Adobe Reader.app/Contents/MacOS/AdobeReader",
"/Applications/Preview.app/Contents/MacOS/Preview"]
fuzz_output = "fuzz.pdf"
FuzzFactor = 250
@hayd
hayd / python-primes-generator.py
Created September 14, 2012 11:54
Primes generator function
class primes():
def __init__(self):
self.primes_list = [2,3]
self.generator = self.generator()
def _append_if_no_prime_divides(self,q):
is_prime = not any( q % p == 0 for p in self.primes_list)
if is_prime:
self.primes_list.append(q)
return is_prime
@hayd
hayd / week1
Last active December 18, 2015 09:49
spectral stuff
import numpy as np
from numpy.fft import fft, fftshift, ifft, fftfreq
L = 10
n = 128
x2 = np.linspace(-L, L, n + 1)
x = x2[1:]
# k = (2 * np.pi / L) * np.concatenate((np.arange(0, n/2), np.arange(-n/2 + 1, 1)))
@hayd
hayd / README.md
Last active December 31, 2015 04:59

test