Skip to content

Instantly share code, notes, and snippets.

@austinschwartz
austinschwartz / Jeopardy.ipynb
Created April 3, 2018 15:49
Jeopardy Python Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@austinschwartz
austinschwartz / recursive_descent_parser.py
Created February 18, 2018 18:26
Python Recursive Descent Parser Example
#!/usr/bin/env python3
import re
from enum import Enum
from collections import namedtuple
"""
Simple Expression Grammar
expr → term {(+ | -) term}
@austinschwartz
austinschwartz / link-local.rb
Created February 4, 2018 21:26
link-local.rb
def parens(n, l = 0, r = 0, curr = ""):
if len(curr) == n:
print(curr)
if l < n // 2:
parens(n, l + 1, r, curr + '(')
if r < l:
parens(n, l, r + 1, curr + ')')
library(scales)
library(ggplot2)
library(ggthemes)
library("devtools")
library("slopegraph")
CSV_Text = '"","jaro","dice","levNorm"
"a shot",0.8888888888888888,1,0.6666666666666667
"keanu (reeves)",0.8714285714285714,0.5333333333333333,0.3571428571428571
"the woodwork",0.8425925925925926,0.8,0.5833333333333333
# Rewriting this this in python:
# https://gist.github.com/beesandbombs/2abe9464e2f43e75807879036a1962ca
import math
recording = False
result = None
N = 16
ia = math.atan(math.sqrt(.5))
@austinschwartz
austinschwartz / randomwalk.tex
Created September 9, 2017 17:25
Random walk figures
% Modified from https://tex.stackexchange.com/a/249320
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}
\pgfmathsetseed{\number\pdfrandomseed}
\begin{document}
\begin{tikzpicture}
@austinschwartz
austinschwartz / multiply.s
Created August 10, 2017 22:41
64-bit tail-recursive multiply w/ two return registers
.section .data
.section .text
@ throughout the program
@ r4 stores m
@ r5 stores n
@ r6 stores the 32-bit LSB of acc (lower 32 bits)
@ r7 stores the 32-bit MSB of acc (higher 32 bits)
@ int multiply(int m, int n, int acc) {
@austinschwartz
austinschwartz / test_in.c
Created March 1, 2017 23:55
CS352 Lab3 Test Case 1
long main(){for(Y=qG[SkBfdSGWx[((FJAmdCw*'u'))]];-636762;UUqxgV=("RLjcdJQyO")){asEHwREpg(tfUwAvibIFe);if(PXqBIEew(Jb,pAt,Lg,jux,okMy,US,hLe,N)){if(-885414.5125210375){while(436485){for(KzuTWYRUrN=(wPL[LKE["UOrmyhvw"]]*(NENNnyXP[(-760952.4360878994||(+'i'))]&&'f'));'k';yMSIlDLMeg=(-*(+"RFs"))){}}{}}}while("jkvqgqXeU"){loUXakm(W,Iqe,I);}}{}for(qRX=I;((("LQgsOETC">24260.031260388205)||yx[nHaqh(j,IU,lMjBa,oRs)])||(('h'/"RDNdGLsN")/'g'));RuuwkW=mvXD(sTTaY,iO,TC,U)){while(("IbQMnAfRN"-(-29940.42566039192))){LnRb(zHb,qO);}}for(O=-966957.704638198;'j';axRBI=292999.3623444184){bMWOc(SlICzzk,RUMI,TRFUytt);for(gA=tTtCGpLLIq;413429;zbJJC=nVCKLs){for(XzRLyYv=-666092;ulzY;HM=ymvV){ReVKv(F,tv);PhpNW(huSnY);}AYrmt(Hgzc,Wj,iJYfAc,eXnZAWc);pHogU(Kq,rKP,il);BYz(JXUO,wlrRY,L);}IPPmKtMUwA(QsZ,wy,p);FNsFHmlSC(OS,uQ);mI(LdQ,sOuim,Pg);cqu(b);cgFi(mnwOD,Qw,xlUGe,Ol,b);Eyo(Yo,VTP,UPM);for(ssIwnksyBq=K(M,TSVH);-999647;Ixu='x'){EAryCRRL(WF,M);{EM(fz,jBeXzEj,BoqkhYt,xwXH);}EWQUIjF(Ml);}vFFYhN(nr);}for(jgGqC=(+-*"Fssxgjnw");PyREQDa;rQlRsd
@austinschwartz
austinschwartz / brackets.py
Created March 1, 2017 20:48
Generates balanced brackets of size n
# http://dl.acm.org/citation.cfm?id=357091
import random, sys
class Generator:
def __init__(self):
self.r = 0
self.k = 0
def open(self):
print("{", end = '')