Skip to content

Instantly share code, notes, and snippets.

@brandonpelfrey
brandonpelfrey / n-pendula.py
Created January 1, 2016 04:47
Automatically Deriving the Angular Accelerations for N-Pendula
from sympy import *
import matplotlib.pyplot as plt
# time variable
t = symbols('t')
# number of pendula + 1
Z = 3 + 1
# Constants
@brandonpelfrey
brandonpelfrey / chess-max-pieces.py
Created December 12, 2015 07:48
Maximizing the Number of Pieces On a Chess Board Without Any Attacking
import pulp, random
from collections import defaultdict
# Some convenience functions for messing with PULP
# This lets us reference variables by any number of strings, numbers etc.
__Variables = {}
def baseVariable(name_tuple, varType):
name = '_'.join( map(str, name_tuple) )
if name not in __Variables: