Skip to content

Instantly share code, notes, and snippets.

View harry830622's full-sized avatar

Harry Chang harry830622

View GitHub Profile
#include <ctime>
#include <iostream>
#include <vector>
using namespace std;
// Assumption: Initializing a vector with size before assignments runs faster
// then filling it by "push_back"s.
int main() {
@harry830622
harry830622 / install.sh
Last active March 10, 2017 08:57
Arch Linux install script
#!/usr/bin/env bash
timedatectl set-ntp true
gdisk /dev/sda
mkfs.vfat /dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt
@harry830622
harry830622 / Makefile
Created January 4, 2017 14:27
Makefile template
EXE = mp
CXX = clang++
CXXFLAGS = -std=c++11 -O2 -Wall
CPPS := $(wildcard src/*.cpp)
OBJS := $(addprefix obj/,$(notdir $(CPPS:.cpp=.o)))
.PHONY: all clean
all: obj $(EXE)
@harry830622
harry830622 / pigeonhole.sh
Last active October 27, 2016 10:31
Generate the CNF of pigeonhole problem in DIMACS format. See also http://www.satcompetition.org/2009/format-benchmarks2009.html
#!/usr/bin/env bash
if [ "$1" = "" ]; then
echo "Please specify the number of holes"
echo "Usage: $0 NUMBER_OF_HOLES"
exit
fi
num_holes="$1"
num_pigeons="$(($1 + 1))"
cell*** ptr_two_d_array = new cell**[m];
for (int i = 0; i < m; ++i) {
cell[i] = new cell*[n];
for (int j = 0; j < n; ++j) {
cell[i][j] = new cell(args...);
}
}
StageName = function(game) {};
(function() {
StageName.prototype = {
preload: function() {
},
create: function() {
},
// Parsing
Node* root = 0;
map<string, Node*> nodes; //container of all nodes, choose map for easy query
vector<Edge*> edges;
vector<Node*> primary_inputs;
vector<Node*> primary_outputs;
string str = "";
while (getline(delay_file, str)) {
stringstream ss(str);
string tmp = "";