From: travis laduke Date: 2005-12-08T14:52:09+09:00 Subject: is this a good way to find anagrams? it seems to me, with computers these days, this should finish instantly, not take like 20 seconds. also, please help me make my ruby more ruby-like. i'm new to ruby, not that i know any other language. ##these are here from when i was first testing secret_word = "spine" rack = "spine" secret_word = secret_word.split(//) rack = rack.split(//) test_rack = rack.to_s ##are there enough of the right letters in the rack to spell the word from the dictionary? ##i think i'm going to use funny spanish names for my methods instead of descriptive names. def rodolfo(secret_word, rack) secret_word.each do |x| rack = rack.to_s if rack.include? x rack = rack.sub(x, '') ##p rack, x else ##puts x, ' rack don\'t work' break end end end puts "reading dictionary" dict = IO.readlines('/usr/share/dict/words') while rack puts "enter rack" rack = gets.chomp.split(//) dict.each do |secret_word| if rodolfo(secret_word.chomp.split(//), rack) puts secret_word.to_s end end end