DEV Community

Discussion on: Daily Challenge #182 - Arrh, grabscrab!

Collapse
 
cipharius profile image
Valts Liepiņš

Ruby

def grabscrab word, dict
    orig = word.chars.sort!
    dict.filter {|entry| entry.chars.sort.eql? orig }
end
Collapse
 
cipharius profile image
Valts Liepiņš

Also was in mood for some Haskell.
This time Haskell solution came out neater than Ruby's

import Data.List (sort)

grabscrab :: String -> [String] -> [String]
grabscrab word = filter $ (patt ==) . sort
    where patt = sort word