Skip to content

Instantly share code, notes, and snippets.

View cameronabrams's full-sized avatar

Cameron Abrams cameronabrams

View GitHub Profile
@cameronabrams
cameronabrams / sb.py
Created October 18, 2021 20:17
Don't cheat at the New York Times Spelling Bee!
''' Cheat at NYT Spelling Bee '''
import random
class Words:
def __init__(self):
with open('/usr/share/dict/words','r') as f:
raw=f.read().split('\n')
self.words=[w.upper() for w in raw if (not "'" in w and len(w)>3 and w.islower())]
self.sevens=[w for w in self.words if (len(w)==7 and len(set(w))==7)]
def findbees(self,letters):
@cameronabrams
cameronabrams / stars_bars.py
Created March 3, 2020 22:02
An iterable stars and bars class in python
import math
import scipy.special as sci
class stars_bars:
def __init__(self,nbins=4,nstars=40):
self.nbins=nbins
self.nstars=nstars
self.bars=[0]*(nbins-1) # bar positions; there are nbins-1 bars
self.bins=[0]*nbins # number of stars in each bin
self.stars=[0]*nstars # bin index of each star
self.index=0 # arrangement counter