Skip to content

Instantly share code, notes, and snippets.

View rharriso's full-sized avatar

Ross Harrison rharriso

View GitHub Profile
@rharriso
rharriso / configure-local-build.sh
Created February 14, 2018 21:50
Installing Nginx Locally
From https://www.vultr.com/docs/how-to-compile-nginx-from-source-on-ubuntu-16-04
./configure --prefix=/home/myusename/nginx/share/nginx \
--sbin-path=/home/myusename/bin/nginx \
--modules-path=/home/myusename/nginx/lib/nginx/modules \
--conf-path=/home/myusename/nginx/nginx.conf \
--error-log-path=/home/myusename/nginx/log/nginx/error.log \
--http-log-path=/home/myusename/nginx/log/nginx/access.log \
--pid-path=/run/nginx.pid \
--lock-path=/home/myusename/nginx/lock/nginx.lock \
@rharriso
rharriso / settings.json
Created August 15, 2017 16:43
Visual Studio Code Editor Settings
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Fira Code",
"editor.fontSize": 12,
"editor.fontLigatures": true,
"editor.lineNumbers": "relative",
"workbench.colorTheme": "Tomorrow Night Blue",
"vim.disableAnnoyingNeovimMessage": true,
"editor.tabSize": 2,
"C_Cpp.intelliSenseEngine": "Default"
@rharriso
rharriso / launch.json
Created July 28, 2017 16:50
VSCode Node debug config
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
available_options = (1..9)
def fillCells:
doFillCells(0)
def doFillCells (index):
cell = board.cells[index]
neighbor_values = cell.neighbors.map((neighbor) => neighbor.values)
remaining_options = available_options \ neighbor_values
----------------------------------
| 3 6 9 | 1 2 4 | 5 8 7 |
| 7 2 8 | 6 5 9 | 3 1 4 |
| 1 4 5 | 7 3 8 | 2 6 9 |
----------------------------------
| 2 9 7 | 3 6 1 | 8 4 5 |
| 5 8 3 | 9 4 2 | 6 7 1 |
| 6 1 4 | 5 8 7 | 9 2 3 |
----------------------------------
| 9 7 2 | 8 1 5 | 4 3 6 |
----------------------------------
| 3 6 9 | 1 2 4 | 5 8 7 |
| 7 2 8 | 6 5 9 | 3 1 4 |
| 1 4 5 | 7 3 8 | 2 6 9 |
----------------------------------
| 2 9 7 | 3 6 1 | 8 4 5 |
| 5 8 3 | 9 4 2 | 6 7 1 |
| 6 1 4 | 5 8 7 | 9 2 3 |
----------------------------------
| 9 7 2 | 8 1 5 | 4 3 6 |
using cellQueue = std::deque<SudokuCell>;
class SudokuBoard {
/*
* fill the board with valid solution
*/
void fillCells() {
auto remaininCells = cellQueue{cells};
if(!doFillCells(remaininCells)) {
----------------------------------
| 7 9 1 | 6 8 4 | 3 2 5 |
| 4 3 8 | 5 2 7 | 9 1 6 |
| 2 6 5 | 3 1 9 | 8 4 7 |
----------------------------------
| 5 4 2 | 7 9 3 | 1 6 8 |
| 6 1 7 | 2 4 8 | 5 |
| | | |
----------------------------------
| | | |
bool fillCells() {
for(auto cell : this->cells()) {
// get first cell and tail
auto cell = remainingCells.front();
remainingCells.pop_front();
set<int> neighborValues = {};
class SudokuBoard {
void generateAllNeighbors () {
// generate row & col neighbors
for (int n = 0; n < 9; ++n) {
neighbors.insert({n, pos.j});
neighbors.insert({pos.i, n});
}
auto iFloor = (pos.i / 3) * THIRD;
auto jFloor = (pos.j / 3) * THIRD;