Skip to content

Instantly share code, notes, and snippets.

View davefernig's full-sized avatar

David Fernig davefernig

View GitHub Profile
import sys
import re
VARIABLE_ASSIGNMENT_REGEX = r'[a-zA-Z_]*='
SQR = 'SQR'
ABS = 'ABS'
INI = '^'
from __future__ import division
from random import randint
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
SAMPLES_PER_N_VALUE = 10000
N_VALUES = [2**n for n in (range(10))]
# Before executing this script, run the following in your terminal:
# virtualenv .
# source bin/activate
# pip install beautifulsoup4
from bs4 import BeautifulSoup
import urllib2
path = "http://www12.statcan.gc.ca/census-recensement/2016/as-sa/98-200-x/2016001/98-200-x2016001-eng.cfm"
def __numpy_to_string(A):
return A.tostring().hex()
def __string_to_numpy(S):
return np.frombuffer(bytes.fromhex(S), dtype=np.float32)
@davefernig
davefernig / dpll
Last active June 4, 2023 18:52
Full code for solving SAT in Python
import seaborn as sns
import pandas as pd
import pylab as plt
import numpy as np
import itertools
import random
import time
def brute_force(cnf):
"""
A tool to calculate probabilities in Perudo.
David Fernig, 2018
"""
from __future__ import division
import scipy.special
class Round(object):