diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2022-04-25 00:30:06 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2022-04-25 00:30:06 +0200 |
commit | 5001e89f399dbd74dab054743f95c752b6f04bc6 (patch) | |
tree | 11c44bf8de00856bf6f139e57873a165e6d6625a /src/main.cpp | |
parent | d1a5218935ed0007832c85150d5697e1e1d8513e (diff) |
Working algorithm, its faster tan light!
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index b66e3be..3144b0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,41 @@ #include "solver.hpp" +#include <iostream> +#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */ +#include <math.h> /* sqrt */ int main() { Solver solver(6); + cube_t cube; + int i; + char *buf = NULL; + size_t sz; + clock_t timer; + + while (getline(&buf, &sz, stdin) != -1) { + init_cube(&cube); + if (sz == 0) break; + printf("> %s\n", buf); + rotate_from_str(&cube, buf); + + dump_cube_grid(&cube); + timer = clock(); + auto result = solver.solve(cube); + timer = clock() - timer; + std::cerr << "Time: " << (float)timer/CLOCKS_PER_SEC << "\n"; + + + for (auto rot: result) { + std::cerr << rot << " "; + } + std::cerr << "\n"; + + for (auto rot: result) { + perform_rotation(&cube, rot); + } + dump_cube_grid(&cube); + } + + if (buf) + free(buf); + } |