Nonogram solver
Revisión | 00e6fc6e0c188c1a8b1e971c22894094d7fe17ae (tree) |
---|---|
Tiempo | 2021-02-11 20:25:03 |
Autor | Alexander Larin <scalar438@gmai...> |
Commiter | Alexander Larin |
Init
@@ -0,0 +1,48 @@ | ||
1 | +AccessModifierOffset: -4 | |
2 | +AlignAfterOpenBracket: Align | |
3 | +AlignConsecutiveAssignments: true | |
4 | +# Must be true. Right now is false because "PointerAlignment: Right" does not work properly | |
5 | +AlignConsecutiveDeclarations: false | |
6 | +AlignEscapedNewlinesLeft: true | |
7 | +AlignTrailingComments: true | |
8 | +AllowShortIfStatementsOnASingleLine: true | |
9 | +AllowShortBlocksOnASingleLine: false | |
10 | +AllowShortCaseLabelsOnASingleLine: true | |
11 | +AllowShortFunctionsOnASingleLine: Inline | |
12 | + | |
13 | + | |
14 | +BinPackArguments: true | |
15 | +BinPackParameters: true | |
16 | + | |
17 | +BreakBeforeBraces: Custom | |
18 | +BraceWrapping: | |
19 | + AfterClass: true | |
20 | + AfterControlStatement: true | |
21 | + AfterEnum: true | |
22 | + AfterFunction: true | |
23 | + AfterNamespace: true | |
24 | + AfterStruct: true | |
25 | + AfterExternBlock: true | |
26 | + IndentBraces: false | |
27 | + BeforeCatch: true | |
28 | + BeforeElse: true | |
29 | + SplitEmptyFunction: false | |
30 | + SplitEmptyRecord: false | |
31 | + SplitEmptyNamespace: false | |
32 | + | |
33 | +BreakBeforeTernaryOperators: false | |
34 | + | |
35 | +ColumnLimit: 100 | |
36 | +ConstructorInitializerAllOnOneLineOrOnePerLine: true | |
37 | +ContinuationIndentWidth: 4 | |
38 | +Cpp11BracedListStyle: true | |
39 | +FixNamespaceComments: true | |
40 | +ForEachMacros: ['foreach', 'Q_FOREACH'] | |
41 | +IndentCaseLabels: false | |
42 | +IndentWidth: 4 | |
43 | +Standard: Cpp11 | |
44 | +TabWidth: 4 | |
45 | +UseTab: ForIndentation | |
46 | +MaxEmptyLinesToKeep: 2 | |
47 | +NamespaceIndentation: None | |
48 | +PointerAlignment: Right |
@@ -0,0 +1,3 @@ | ||
1 | +syntax: glob | |
2 | +CMakeLists.txt.user | |
3 | +build/ |
@@ -0,0 +1,5 @@ | ||
1 | +cmake_minimum_required(VERSION 3.10) | |
2 | +project(NonogramSolver) | |
3 | + | |
4 | +add_executable(main main.cpp row_solver.cpp cell.cpp) | |
5 | +set_property(TARGET main PROPERTY CXX_STANDARD 17) | |
\ No newline at end of file |
@@ -0,0 +1,25 @@ | ||
1 | +#pragma once | |
2 | +#include <optional> | |
3 | + | |
4 | +const int MAX_COLORS = 31; | |
5 | + | |
6 | +class Cell | |
7 | +{ | |
8 | + explicit Cell(int max_colors); | |
9 | + | |
10 | + /// Return 0 (background color) or color number (number from 1 to MAX_COLORS) if cell state is | |
11 | + /// determined If not, return nullopt | |
12 | + std::optional<int> get_color() const; | |
13 | + | |
14 | + bool is_color_possible(int color_number) const; | |
15 | + | |
16 | + bool is_impossible() const; | |
17 | + | |
18 | + void set_color_possible(int color_number, bool possible); | |
19 | + | |
20 | +private: | |
21 | + // Bitmask with possible colors. 0 - "impossible" cell, it mustn't appear in normal puzzless | |
22 | + // Least bit is background (i.e. if m_data == 0 then cell is background) all other bits are | |
23 | + // colors | |
24 | + uint32_t m_data; | |
25 | +}; |
@@ -0,0 +1,4 @@ | ||
1 | +int main() | |
2 | +{ | |
3 | + | |
4 | +} | |
\ No newline at end of file |
@@ -0,0 +1,2 @@ | ||
1 | +#include "row_solver.hpp" | |
2 | + |
@@ -0,0 +1,9 @@ | ||
1 | +#pragma once | |
2 | +#include "cell.hpp" | |
3 | +#include <vector> | |
4 | + | |
5 | +/// Calculate puzzle for one row. | |
6 | +/// @param cells - row, vector of cells with current state | |
7 | +/// @param block_list - vector of pair (color number, block length) | |
8 | +/// @return number of cells with changed state | |
9 | +std::vector<int> adjust(std::vector<Cell> &cells, std::vector<std::pair<int, int>> &block_list); | |
\ No newline at end of file |