#include <iostream>
#include <vector>
#include "text.hpp"

using namespace std;

void show_histogram_text(const vector<size_t>& baskets) {
    const size_t screen_width = 80;
    const size_t max_asterisk = screen_width - 3 - 1;
    cout.precision(4);
    size_t baskets_max_count;
    
    baskets_max_count = baskets[0];
    for (size_t i : baskets) {
        if (i > baskets_max_count) baskets_max_count = i;
    }
    for (int i = 0; i < baskets.size(); i++) {
        size_t height = baskets[i];
        if (baskets_max_count > max_asterisk) {
            height = max_asterisk * (static_cast<double>(baskets[i]) / baskets_max_count);
        }
        cout << baskets[i] << "|";
        for (int j = 0; j < height; j++) cout << "*";
        cout << endl;
    }
}