aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 3144b0b54da59cd7d161527396fc2a51286cfa96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);

}