Skip to content

Instantly share code, notes, and snippets.

View deleted's full-sized avatar

Ted Scharff deleted

View GitHub Profile
@deleted
deleted / planagrams
Last active August 29, 2015 14:13 — forked from msmoot/planagrams
#!/usr/bin/env python
# An anagram is a word formed by rearranging the letters of another, like "topside" and
# "deposit". In some cases, there might be as many (or more) anagrams than there are
# characters, like "post", "spot", "stop" and "tops".
#
# Write a program to find all of the anagrams in a dictionary in which there are at
# least 4 letters in the word and at least as many anagrams as there are letters.
#
# The dictionary will be a file on disk with one line per word. Your operating system
# likely already has such a file in /usr/dict/words or /usr/share/dict/words.
# Create a deep copy of an object. - Based on https://github.com/documentcloud/underscore/pull/595
deepClone = (obj) ->
if !_.isObject obj or _.isFunction obj then return obj
if _.isDate obj then return new Date do obj.getTime
if _.isRegExp obj then return new RegExp obj.source, obj.toString().replace(/.*\//, "")
isArr = _.isArray obj or _.isArguments obj
func = (memo, value, key) ->
if isArr then memo.push deepClone value