#include "text.h"
<<<<<<< HEAD
#include <iostream>

void show_histogram(const std::vector<size_t>& bins) {


    bool gigant = false;
    auto spaces = 0;
    size_t mx_count = 0;

    for (auto x : bins) {
        if (x > 76) gigant = true;
        if (x > mx_count) mx_count = x;

        auto len = 0;
        auto num = x;
        while (num > 0) {
            num /= 10;
            len++;
        }
        if (len > spaces) spaces = len;
    }

    for (size_t i = 0; i < bins.size(); i++) {

        int len = 1;
        auto num = bins[i];
        for (; num /= 10; ++len);
        while (len < spaces) {
            std::cout << " ";
            len++;
        }
        std::cout << bins[i] << "|";


        if (gigant) {
            size_t stars = (mx_count > 0) ? (76 * bins[i] / mx_count) : 0;
            for (size_t j = 0; j < stars; j++) {
                std::cout << "*";
            }
        } else {
            for (size_t j = 0; j < bins[i]; j++) {
                std::cout << "*";
            }
        }
        std::cout << std::endl;
=======

void show_histogram(std::vector<size_t> bins) {
    bool gigant = false;
    auto spaces = 0;
    size_t mx_count = 0;
    for (auto x : bins) {
        if (x > 76) {
            gigant = true;
        }
        if (x > mx_count) {
            mx_count = x;
        }
        auto len = 0;
        while (x > 0) {
            x /= 10;
            len++;
        }
        if (len > spaces) {
            spaces = len;
        }

    }
    if (spaces == 1) {
        for (size_t i = 0; i < bins.size(); i++) {
            std::cout << "  " << bins[i] << "|";
            if (gigant) {
                if (bins[i] == mx_count) {
                    for (size_t j = 0; j < 76; j++) {
                        std::cout << "*";
                    }
                }
                else
                {
                    for (size_t j = 0; j < 76 * static_cast<double>(bins[i]) / mx_count; j++) {
                        std::cout << "*";
                    }
                }
            }
            else
            {
                for (size_t j = 0; j < bins[i]; j++) {
                    std::cout << "*";
                }
                std::cout << std::endl;
            }
        }
    }
    else
    {
        for (size_t i = 0; i < bins.size(); i++) {
            int len = 1;
            int k = bins[i];
            for (; k /= 10; ++len);
            while (len < spaces) {
                std::cout << " ";
                len++;
            }
            std::cout << bins[i];
            std::cout << "|";
            if (gigant) {
                if (bins[i] == mx_count) {
                    for (size_t j = 0; j < 76; j++) {
                        std::cout << "*";
                    }
                }
                else
                {
                    for (size_t j = 0; j < (76 * static_cast<double>(bins[i]) / mx_count - 1); j++) {
                        std::cout << "*";
                    }
                }
            }
            else
            {
                for (size_t j = 0; j < bins[i]; j++) {
                    std::cout << "*";
                }
            }
            std::cout << std::endl;
        }
>>>>>>> origin/main
    }
}
