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.78 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.77 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.76 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.75 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.74 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.73 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.72 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.71 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.70 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.69 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.68 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.67 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.66 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.65 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.64 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.63 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.62 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.61 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.60 tracks/cpp/exercises/scrabble-score/example.cpp
trackler-2.2.1.59 tracks/cpp/exercises/scrabble-score/example.cpp