Skip to content

Instantly share code, notes, and snippets.

@spence
spence / find_anagrams.py
Created May 17, 2015 14:17
Given a string of words, find all those that are anagrams.
def find_anagrams(words):
"""
Find anagrams in O(n*m) time and O(n) space.
Notes: returns all words in input that are anagrams of another word.
"""
anagrams = []
sorted_words = {}
for word in words: # O(n)
def get_products_of_all_ints_except_at_index(int_array):
"""
Single pass.
"""
# Condition where element has neither left nor right elements
if len(int_array) == 1:
# Maybe [None] ?
return [0]
@spence
spence / phantomjs-repl.sh
Last active August 29, 2015 14:19
Bash PhantomJS REPL modeled after https://github.com/sotownsend/BooJS
#!/usr/bin/env bash
### Repl Usage:
#
# $ ./phantomjs-repl.sh
# > missing
# ReferenceError: Can't find variable: missing
# > window
# [object Window]
# > console.log('Hello')