Sha256: 6dca1a8d93e939457fcd68ff50ff57167208ae2e2ac706430caac428c505f787

Contents?: true

Size: 684 Bytes

Versions: 396

Compression:

Stored size: 684 Bytes

Contents

#include "scrabble_score.h"
#include <cctype>

namespace scrabble_score
{

namespace
{
const int letter_scores[26] = {
    1,  // A
    3,  // B
    3,  // C
    2,  // D
    1,  // E
    4,  // F
    2,  // G
    4,  // H
    1,  // I
    8,  // J
    5,  // K
    1,  // L
    3,  // M
    1,  // N
    1,  // O
    3,  // P
    10, // Q
    1,  // R
    1,  // S
    1,  // T
    1,  // U
    4,  // V
    4,  // W
    8,  // X
    4,  // Y
    10  // Z
};

}

int score(const std::string &word)
{
    int result = 0;
    for (const char c : word) {
        if (std::isalpha(c)) {
            result += letter_scores[std::tolower(c) - 'a'];
        }
    }
    return result;
}

}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.97 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.96 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.95 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.94 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.93 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.92 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.91 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.90 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.89 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.88 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.87 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.86 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.85 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.84 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.83 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.82 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.81 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.80 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.79 tracks/cpp/exercises/scrabble-score/example.cpp