Sha256: b584b6757b1dfb3c44f7763b3d758c0a9156aeee8fa7182a3b1f23890b765b81

Contents?: true

Size: 297 Bytes

Versions: 396

Compression:

Stored size: 297 Bytes

Contents

#include "trinary.h"

namespace trinary
{

int to_decimal(std::string const &text)
{
    int result = 0;
    for (const char digit : text) {
        if (digit < '0' || digit > '2') {
            return 0;
        }
        result *= 3;
        result += digit - '0';
    }
    return result;
}

}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.179 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.178 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.177 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.176 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.175 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.174 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.173 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.172 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.171 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.170 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.169 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.167 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.166 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.165 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.164 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.163 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.162 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.161 tracks/cpp/exercises/trinary/example.cpp
trackler-2.2.1.160 tracks/cpp/exercises/trinary/example.cpp