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.180 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.179 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.178 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.177 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.176 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.175 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.174 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.173 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.172 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.171 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.170 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.169 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.167 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.166 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.165 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.164 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.163 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.162 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.161 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.160 tracks/cpp/exercises/scrabble-score/example.cpp