Skip to content

Instantly share code, notes, and snippets.

View rharriso's full-sized avatar

Ross Harrison rharriso

View GitHub Profile
@rharriso
rharriso / .zshrc
Created February 15, 2017 15:49
osx .zshrc
source ~/.profile
export ZSH=/Users/{USER}/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
# autojump
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
# attach and detach for node debugger
'atom-text-editor':
'F4': 'node-debugger:attach'
'shift-F4': 'node-debugger:stop'
# exec command for vim
'atom-text-editor.vim-mode-plus.normal-mode':
':': 'vim-mode-plus-ex-mode:open'
'!': 'vim-mode-plus-ex-mode:toggle-setting'
@rharriso
rharriso / yo.js
Last active March 16, 2017 00:51
alert('yo');
struct coord {
int i = 0;
int j = 0;
};
// equality comparison between two coors
inline bool operator == (const coord &lhs, const coord &rhs) {
return lhs.i == rhs.i && lhs.j == rhs.j;
}
----------------------------------
| | 7 | |
| | 7 | |
| | 7 | |
----------------------------------
| 7 7 7 | 6 7 7 | 7 7 7 |
| | 7 7 7 | |
| | 7 7 7 | |
----------------------------------
class SudokuCell {
public:
coord pos;
set<coord> neighbors{};
int value = 0;
// set position and generate neighbors
void setPosition(coord pos);
private
using cellQueue = queue<shared_ptr<SudokuCell>>;
class SudokuBoard {
cellQueue cells;
public:
// initialize board
SudokuBoard(){/* ... */}
// fill the board with valid solution
void fillCells(){/* ... */}
// adjust to deque for pushing back on front
using cellQueue = deque<shared_ptr<SudokuCell>>;
class SudokuBoard {
cellQueue cells;
public
/*
* .....
*/
bool fillCells() {
for(auto cell : this->cells()) {
// get first cell and tail
auto cell = remainingCells.front();
remainingCells.pop_front();
set<int> neighborValues = {};
----------------------------------
| 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 |
| | | |
----------------------------------
| | | |