Sha256: 7c6be3a0e8c2f8ecd8b1a17cb2e10cb3a576d06f2e907bf792888645258e0839

Contents?: true

Size: 734 Bytes

Versions: 84

Compression:

Stored size: 734 Bytes

Contents

-module(scrabble_score).

-export([score/1]).

score( Word ) ->
  lists:foldl(fun(X, Sum) -> get_char_value(X) + Sum end, 0, Word).

get_char_value( $q ) -> 10;
get_char_value( $z ) -> 10;
get_char_value( $j ) ->  8;
get_char_value( $x ) ->  8;
get_char_value( $k ) ->  5;
get_char_value( $f ) ->  4;
get_char_value( $h ) ->  4;
get_char_value( $v ) ->  4;
get_char_value( $w ) ->  4;
get_char_value( $y ) ->  4;
get_char_value( $b ) ->  3;
get_char_value( $c ) ->  3;
get_char_value( $m ) ->  3;
get_char_value( $p ) ->  3;
get_char_value( $d ) ->  2;
get_char_value( $g ) ->  2;
get_char_value( C ) when C >= $a, C =< $z ->  1;
get_char_value( C ) when C >= $A, C =< $Z ->
  [C2] = string:to_lower( [C] ),
  get_char_value( C2 ).  

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
trackler-2.0.6.28 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.27 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.26 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.25 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.24 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.23 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.22 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.21 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.20 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.19 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.18 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.17 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.16 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.15 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.14 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.13 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.12 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.11 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.10 tracks/erlang/exercises/scrabble-score/example.erl
trackler-2.0.6.9 tracks/erlang/exercises/scrabble-score/example.erl