This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"vim:fileencoding=utf-8:ft=conf:foldmethod=marker | |
" General {{{ | |
" These are general settings that work on both Vim/Neovim. They mostly relate | |
" to saner defaults like `hidden` buffers, `unnamed` clipboard etc. They've | |
" been heavily commented to make sense to the future reader (most likely me!). | |
set hidden "hidden buffers are allowed. This allows me to move around files without saving them. | |
set clipboard=unnamed "unnamed clipboard unifies the system clipboard and Vim's clipboard. | |
set ignorecase "ignorecases allows for case insensitive pattern matching during search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start window and pane numbering from 1 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
# Vi bindings | |
set -g status-keys vi | |
# renumber windows on close | |
set -g renumber-windows on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <string> | |
#include <unordered_map> | |
#include <unordered_set> | |
#include <queue> | |
#include <stack> | |
#include <algorithm> | |
#include <cassert> | |
#include <iostream> | |
#include <cstdio> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
There are three sections of the list: | |
1. The part before the sub list that gets reversed | |
2. The actual sub list that gets reversed | |
3. The part after the sub list that gets reversed | |
When reversing the entire list, (1) and (3) are empty, and (2) is the entire list. | |
In the following code: | |
• You need to traverse the list until you get to the p'th node and then only reverse 'q - p + 1' times (length of the window) | |
○ When reversing the entire list, p = 0 and q = length of list - 1 so you don't need to do this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <vector> | |
#include <queue> | |
#include <cstdio> | |
#include <unordered_set> | |
#include <limits> | |
#include <functional> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct Foo { | |
char a; | |
int b; | |
char c; | |
}; | |
// This little program shows how memory alignment can affect layout in memory, and how compilers do extra | |
// work to insert padding into your structures. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
// 16 byte struct | |
typedef struct Node { | |
int64_t value; | |
struct Node* next; | |
} Node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
/** | |
* Easy way to distinguish between the 3 traversal methods is to check the position of the root. | |
* If the root comes first -> pre-order | |
* If the root comes last -> post-order | |
* If the root comes in the middle -> in-order. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tic Tac Toe using Minmax search with Alpha Beta Pruning. | |
* | |
* Author: Srishan Bhattarai | |
* | |
* Compile: g++ -g --std=c++11 ttt.cc -o ttt | |
* | |
* Follow the "get_ai_move" function to see the algorithm in action, rest of | |
* the code is to get user input, render board into terminal, check for goal | |
* states etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::error::Error; | |
use std::fs::File; | |
use std::io::{BufRead, BufReader}; | |
use std::path::Path; | |
struct MarkovChain { | |
order: usize, | |
chain: HashMap<Vec<String>, HashMap<String, usize>>, | |
freqs: HashMap<Vec<String>, usize>, |
NewerOlder