#include "counter.h"


void counter::Counter::countPair(std::unordered_map<std::string, long>& map, const std::string& input)
{
    for (int i = 1; i < input.size(); i++)
    {
        const auto pair = input.substr(i - 1, 2);

        map[pair] += 1;
    }
}

void counter::Counter::countTriple(std::unordered_map<std::string, long>& map, const std::string& input)
{
    for (int i = 2; i < input.size(); i++)
    {
        const auto pair = input.substr(i - 2, 3);

        map[pair] += 1;
    }
}

std::unordered_map<std::string, long> counter::Counter::count(const std::string& input)
{
    std::unordered_map<std::string, long> map;

    countPair(map, input);
    countTriple(map, input);

    return map;
}


