Skip to content

Commit

Permalink
more IQ puzzle, cleanup, refactor 2d grid tilings
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzm committed Jun 19, 2024
1 parent fef764f commit 962230b
Show file tree
Hide file tree
Showing 23 changed files with 341 additions and 513 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13)
project(dlx)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 0 additions & 2 deletions common/Element.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <string>

#include "Element.hpp"

using namespace std;
Expand Down
2 changes: 2 additions & 0 deletions common/Element.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef ELEMENT_H
#define ELEMENT_H

#include <string>

class Header;

class Element
Expand Down
7 changes: 4 additions & 3 deletions common/Matrix.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "Matrix.hpp"

#include "Element.hpp"

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#include "Matrix.hpp"
#include "Element.hpp"

using namespace std;


Expand Down
7 changes: 2 additions & 5 deletions common/Matrix.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#ifndef MATRIX_H
#define MATRIX_H

#include <functional>
#include <map>
#include <string>
#include <vector>

#include "Element.hpp"

#include <map>


class Matrix
{
Expand Down
5 changes: 2 additions & 3 deletions common/Puzzle.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <iostream>
#include <vector>

#include "Puzzle.hpp"

#include "Matrix.hpp"

#include <iostream>

using namespace std;


Expand Down
7 changes: 4 additions & 3 deletions common/Puzzle.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef PUZZLE_H
#define PUZZLE_H

#include <vector>

#include "Matrix.hpp"

#include <vector>

class Element;


class Puzzle
{
public:
Expand All @@ -18,7 +19,7 @@ class Puzzle
protected:

virtual void init() = 0;
virtual void print(std::vector<Element *>& solution) = 0;
virtual void print(std::vector<Element *> const& solution) = 0;

struct SubGoal {
Matrix matrix;
Expand Down
12 changes: 6 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

#include "Iq.hpp"
#include "Pentominoes.hpp"
#include "Pyramid.hpp"
Expand All @@ -14,6 +8,12 @@
#include "boost/any.hpp"
#include "boost/program_options.hpp"

#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

using namespace std;
namespace po = boost::program_options;

Expand Down
4 changes: 2 additions & 2 deletions queens/Queens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void Queens::init()
}


void Queens::print(vector<Element *>& solution)
void Queens::print(vector<Element *> const& solution)
{
static int count = 0;

Expand All @@ -92,7 +92,7 @@ void Queens::print(vector<Element *>& solution)
cout << "#" << ++count << ":" << endl;
for(int f=0; f<n; ++f) {
for(int r=0; r<n; ++r) {
cout << (queens.count(pair<int, int>(r, f)) ? "\u265b " : "\u30fb");
cout << (queens.count(pair<int, int>(r, f)) ? "\u265b " : "\u30fb");
}
cout << endl;
}
Expand Down
7 changes: 4 additions & 3 deletions queens/Queens.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef QUEENS_H
#define QUEENS_H

#include <vector>

#include "Puzzle.hpp"

#include <vector>

class Element;
class Matrix;


class Queens : public Puzzle
{
public:
Expand All @@ -17,7 +18,7 @@ class Queens : public Puzzle
private:

void init() override;
void print(std::vector<Element *>& solution) override;
void print(std::vector<Element *> const& solution) override;

int n;

Expand Down
6 changes: 3 additions & 3 deletions sudoku/Sudoku.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "Sudoku.hpp"

#include <iostream>
#include <sstream>

#include "Sudoku.hpp"

using namespace std;


Expand Down Expand Up @@ -87,7 +87,7 @@ void Sudoku::init()
}


void Sudoku::print(std::vector<Element *>& solution)
void Sudoku::print(std::vector<Element *> const& solution)
{
int board[9][10]={0};
for(auto& e: solution) {
Expand Down
3 changes: 2 additions & 1 deletion sudoku/Sudoku.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Puzzle.hpp"


class Sudoku : public Puzzle
{
public:
Expand All @@ -12,7 +13,7 @@ class Sudoku : public Puzzle
private:

void init() override;
void print(std::vector<Element *>& solution) override;
void print(std::vector<Element *> const& solution) override;

};

Expand Down
2 changes: 2 additions & 0 deletions tiling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
add_library(tiling OBJECT
Iq.cpp
Iq.hpp
Ortho2d.cpp
Ortho2d.hpp
Pentominoes.cpp
Pentominoes.hpp
Pyramid.cpp
Expand Down
Loading

0 comments on commit 962230b

Please sign in to comment.