#include "solver/solver.h"

#include <sstream>

Solver::Solver(std::string string) : puzzle_(Puzzle::FromString(string)) {}

bool Solver::Solve() {
  while (puzzle_.ApplyNextStep()) {
  }
  return puzzle_.IsSolved();
}

std::string Solver::State() { return puzzle_.CurrentState(); }

std::string Solver::StateUrl() {
  std::ostringstream stream;
  stream << "https://tiramisu.one/sudoku.html?p=" << puzzle_.CurrentState()
         << "&m=" << puzzle_.PencilMarkState();
  return stream.str();
}
