80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
#include <bitset>
|
|
#include <array>
|
|
#include <span>
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <algorithm>
|
|
#include <vector>
|
|
#include "VoxelSpace.h"
|
|
#include "SomaSolve.h"
|
|
|
|
auto get_dims_input(int dims[3]) -> void {
|
|
std::cout << "Enter dimensions separated by newlines. (x*y*z must not exceed 64)\n";
|
|
auto success = false;
|
|
while (!success) {
|
|
std::cout << "x: ";
|
|
std::cin >> dims[0];
|
|
std::cout << "y: ";
|
|
std::cin >> dims[1];
|
|
std::cout << "z: ";
|
|
std::cin >> dims[2];
|
|
|
|
auto size = dims[0]*dims[1]*dims[2];
|
|
if (size <= 64) {
|
|
success = true;
|
|
} else {
|
|
std::cout << "That resulted in " << size << " units. Try again.\n";
|
|
}
|
|
std::cin.ignore();
|
|
}
|
|
}
|
|
|
|
auto get_reprs_input(int units_required) -> std::vector<uint64_t> {
|
|
std::cout << "Enter bit-representations (big endian, max 64 bits, total 1s must add up to " << units_required << "). press ENTER twice to finish input.\n";
|
|
auto reprs = std::vector<uint64_t>();
|
|
auto total_units = 0;
|
|
while (true) {
|
|
auto input = std::string();
|
|
std::getline(std::cin, input);
|
|
if (input.size() == 0) {
|
|
if (total_units == units_required) {
|
|
break;
|
|
} else {
|
|
std::cout << "Bad number of units. You entered: " << total_units << ", but exactly " << units_required << " were required.\n";
|
|
total_units = 0;
|
|
continue;
|
|
}
|
|
}
|
|
auto bit_repr = 0ul;
|
|
auto i = 0;
|
|
auto good_repr = true;
|
|
for (auto it = input.rbegin(); it < input.rend(); it++, i++) {
|
|
if (*it == '1') {
|
|
bit_repr |= 1ul << i;
|
|
total_units++;
|
|
} else if (*it != '0' || i >= 64) {
|
|
std::cout << "Input invalid. Enter a binary string only with max 64 bits." << '\n';
|
|
good_repr = false;
|
|
break;
|
|
}
|
|
}
|
|
if (good_repr) {
|
|
reprs.push_back(bit_repr);
|
|
}
|
|
}
|
|
return reprs;
|
|
}
|
|
|
|
|
|
auto main() -> int {
|
|
int dims[3] = { 3, 3, 3 };
|
|
//get_dims_input(dims);
|
|
//std::cout << '\n';
|
|
//auto reprs = get_reprs_input(dims[0]*dims[1]*dims[2]);
|
|
std::cout << "Great. Calculating solutions...\n";
|
|
auto solutions = SomaSolve::solve(&SomaSolve::STD_SOMA, std::array<int, 3>{ 3, 3, 3 }.data());
|
|
std::cout << solutions.size() << " solutions found." << std::endl;
|
|
return 0;
|
|
}
|