Skip to content

Instantly share code, notes, and snippets.

View jeffreybaird's full-sized avatar

Jeffrey Baird jeffreybaird

View GitHub Profile
@agoodman
agoodman / subtract_letters.rb
Created May 24, 2012 22:42
Word Pruning by Letter Subtraction
possible_words = ["seek", "find", "ignore", "pursue", "covet"]
available_letters = ["a", "c", "e", "f", "g", "i", "n", "o", "p", "r", "t", "u", "v"]
words = Array[possible_words].flatten
available_letters.each {|e| words = words.map {|w| w.sub(e, '')}}
viable_words = words.each_with_index.collect {|w,k| possible_words[k] if w==""}.compact