Skip to content

Instantly share code, notes, and snippets.

View stevenschmatz's full-sized avatar
🏠
Working from home

Steven Schmatz stevenschmatz

🏠
Working from home
View GitHub Profile
@stevenschmatz
stevenschmatz / gen_fibonacci_plots.py
Last active December 8, 2017 19:28
Exponential computation time of naive Fibonacci algorithm
from time import time
from typing import List
import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
def fibonacci_naive(n: int) -> int:
if n <= 2: return 1
return fibonacci_naive(n-1) + fibonacci_naive(n-2)
@stevenschmatz
stevenschmatz / debugprint.py
Created September 20, 2017 21:40
Value function + policy debugging
def print_value_function(v):
for i in range(4):
for j in range(4):
print("%.3f" % v[i*4 + j], end=' ')
print()
def print_policy(policy):
characters = ['←', '↓', '→', '↑']
for i in range(4):
@stevenschmatz
stevenschmatz / sieve.py
Created August 21, 2017 01:16
Sieve of Eratosthenes
from collections import OrderedDict
def sieve_of_eratosthenes(n):
"""Generates primes up to n, inclusive."""
candidates = OrderedDict((i, None) for i in range(2, n + 1))
primes = []
while len(candidates) > 0:
prime = list(candidates.keys())[0]
#include <iostream>
#include <exception>
#include <stdlib.h>
using namespace std;
/*
* Your tasks:
* - Fill in missing pieces in the code
* - Fix any bugs in the program

Keybase proof

I hereby claim:

  • I am stevenschmatz on github.
  • I am stevenschmatz (https://keybase.io/stevenschmatz) on keybase.
  • I have a public key whose fingerprint is EF13 AC76 A87C 097E 44F6 01EC 9FCA 2E6B 7D86 BEDE

To claim this, I am signing this object:

@stevenschmatz
stevenschmatz / index.html
Created September 9, 2014 02:38
Caliper and ruler error – for Shane McPartlin
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Helping Shane</title>
</head>
<body>
<script>
var calculateError = function(length) {