#include <iostream>
#include <vector>
#include <cmath>
#include "histogram.h"
#include "svg.h"

using namespace std;
int inbl()
{
    int BLOCK_WIDTH;
    cerr << "block width is";
    cin>>BLOCK_WIDTH;
    if (BLOCK_WIDTH>30)
    {
        cerr<< "too big, please make it smaller";
        inbl;
    }
    else if (BLOCK_WIDTH<3)
    {
        cerr<< "too small, please make it bigger";
        inbl;
    }
    else return BLOCK_WIDTH;

}
struct Input
{
    vector<double> numbers;
    int bin_count;
    int BLOCK_WIDTH;
};
Input
input_data()
{
    size_t number_count=0;
    cerr<<"amount of numbers is";
    cin >> number_count;
Input in;
    in.numbers.resize(number_count);
    cerr<<"let's intro numbers ";
    for (size_t i = 0; i < number_count; i++)
    {
        cin >> in.numbers[i];
    }
    size_t bin_count=0;
    cerr<<"amount of bins is";
    cin >> in.bin_count;
    int BLOCK_WIDTH = inbl();
    return in;
}
//4199705
//0x71fdf8
//4199705

int main()
{
    auto in = input_data();



            //std::cout<<in.bin_count<<endl;


    auto bins = make_histogram(in.numbers, in.bin_count);
    show_histogram_svg(bins,in.BLOCK_WIDTH);


    return 0;
}
