Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from hackling/scrabble.ex
Last active May 31, 2017 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radar/d7bad51d3fe10c7f0180d704e6a56144 to your computer and use it in GitHub Desktop.
Save radar/d7bad51d3fe10c7f0180d704e6a56144 to your computer and use it in GitHub Desktop.
defmodule Scrabble do
def score(l) when l in [nil, ""] do: 0
def score(l) when l in ["A", "E", "I", "O", "U"] do: 1
def score(word) do
word
|> String.upcase
|> String.split("")
|> Enum.map(&(score(&1)))
|> Enum.sum
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment