Revisions
-
hackling revised this gist
May 31, 2017 . 1 changed file with 28 additions and 12 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,39 @@ defmodule Scrabble do def score(nil), do: 0 def score(""), do: 0 def score("A"), do: 1 def score("B"), do: 3 def score("C"), do: 3 def score("D"), do: 2 def score("E"), do: 1 def score("F"), do: 4 def score("G"), do: 2 def score("H"), do: 4 def score("I"), do: 1 def score("J"), do: 8 def score("K"), do: 5 def score("L"), do: 1 def score("M"), do: 3 def score("N"), do: 1 def score("O"), do: 1 def score("P"), do: 3 def score("Q"), do: 10 def score("R"), do: 1 def score("S"), do: 1 def score("T"), do: 1 def score("U"), do: 1 def score("V"), do: 4 def score("W"), do: 4 def score("X"), do: 8 def score("Y"), do: 4 def score("Z"), do: 10 def score(word) do word |> String.upcase |> String.split("") |> Enum.map(&(score(&1))) |> Enum.sum end end -
radar revised this gist
May 31, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ defmodule Scrabble do |> String.upcase |> String.split("") |> Enum.reject(&(&1 == "")) |> Enum.map(&(@letters[&1])) |> Enum.sum end end -
radar created this gist
May 31, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ defmodule Scrabble do @letters %{ "A" => 1, "B" => 3, "C" => 3, "D" => 2, "E" => 1, "F" => 4, "G" => 2, "H" => 4, "I" => 1, "J" => 8, "K" => 5, "L" => 1, "M" => 3, "N" => 1, "O" => 1, "P" => 3, "Q" => 10, "R" => 1, "S" => 1, "T" => 1, "U" => 1, "V" => 4, "W" => 4, "X" => 8, "Y" => 4, "Z" => 10 } def score(nil), do: 0 def score(""), do: 0 def score(word) do word |> String.upcase |> String.split("") |> Enum.reject(&(&1 == "")) |> Enum.map(fn (letter) -> @letters[letter] end) |> Enum.sum end end