Skip to content

Instantly share code, notes, and snippets.

@eliotl
eliotl / alice_compromise.py
Last active September 27, 2019 15:32
Implementation of the game described in https://projecteuler.net/problem=503; Paired on with Louis Hyde
import random
class Deck():
def __init__(self, n=3):
self.cards = list(range(1,n+1))
random.shuffle(self.cards)
self.position = 0
def __len__(self):
return len(self.cards)
def _number_of_cards_left(self):
@eliotl
eliotl / hollowpm.py
Last active May 5, 2021 21:11
hollowPM - Hollow Phonetic Matrix module
"""
This is my Hollow Phonetics Matrix module: It is for handling different poetic
word search operations for my Flask website (https://puns.plus) It is a handler
for three large 45,000 x 45,000 nearest neighbor matrices that are too big for
me to want to load into memory. (One for overall sound similarity, one for
word2vec meaning similarity, and one for presence of individual phonetic features.)
Given different search requests, this translates from search word to vector
number, unpickles individual vectors from the disk as needed, performs the
necessary math, and then renders the results as words.