// Crea los archivos de prueba del paso 6 en la carpeta que se le indique. Con semilla fija.
#include <cstdint>
#include <fstream>
#include <iostream>
#include <random>
#include <string>
#include <vector>

namespace {

void save(const std::string& path, const std::vector<std::uint8_t>& bytes) {
    std::ofstream out(path, std::ios::binary);
    out.write(reinterpret_cast<const char*>(bytes.data()), static_cast<std::streamsize>(bytes.size()));
}

}  // namespace

int main(int argc, char** argv) {
    if (argc != 2) {
        std::cerr << "uso: make_samples carpeta\n";
        return 2;
    }
    const std::string folder = std::string(argv[1]) + "/";
    save(folder + "empty.bin", {});
    save(folder + "one_byte.bin", {0xFF});
    save(folder + "single_symbol.bin", std::vector<std::uint8_t>(100000, 'a'));

    std::vector<std::uint8_t> all_bytes;
    for (int round = 0; round < 1000; round++) {
        for (int value = 0; value < 256; value++) {
            all_bytes.push_back(static_cast<std::uint8_t>(value));
        }
    }
    save(folder + "all_bytes.bin", all_bytes);

    std::mt19937 generator(13);
    std::vector<std::uint8_t> random_bytes(1 << 20);
    for (std::uint8_t& byte : random_bytes) {
        byte = static_cast<std::uint8_t>(generator() >> 24);
    }
    save(folder + "random.bin", random_bytes);

    // Dos bytes difíciles y fines de línea, con pocos símbolos distintos.
    const std::vector<std::uint8_t> tricky = {0x00, 0xFF, 0x0A, 0x0D, 0x1A};
    std::vector<std::uint8_t> special(100000);
    for (std::uint8_t& byte : special) {
        byte = tricky[generator() % tricky.size()];
    }
    save(folder + "special.bin", special);
    return 0;
}
