Skip to content

Instantly share code, notes, and snippets.

View spaghetti-source's full-sized avatar

Takanori MAEHARA spaghetti-source

View GitHub Profile
@spaghetti-source
spaghetti-source / knapsack.cc
Last active August 29, 2015 13:57
knapsack
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <functional>
#include <algorithm>
#include <numeric>
using namespace std;
@spaghetti-source
spaghetti-source / animatedbar.py
Created March 22, 2014 02:27
animated bar graph
# -*- coding: UTF-8 -*-
#
# source: http://www.mext.go.jp/b_menu/toukei/001/022/2003.htm
#
import random
import matplotlib
import matplotlib.pyplot as plt
import math
y = [53.14, 52.44, 54.13, 54.63, 54.40, 54.85, 51.04, 50.35, 49.29, 47.95, 47.05, 45.28, 42.62, 39.70, 36.86]
@spaghetti-source
spaghetti-source / iitomo.txt
Created March 31, 2014 06:47
waratte iitomo telephone shocking dataset
1982/10/4 桜田淳子
1982/10/5 土居甫
1982/10/6 増田恵子
1982/10/7 うつみ宮土理
1982/10/8 和田アキ子
1982/10/11 ガッツ石松
1982/10/12 加藤芳郎
1982/10/13 富永一朗
1982/10/14 鈴木義司
1982/10/15 三波豊和
#include <iostream>
#include <vector>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
@spaghetti-source
spaghetti-source / loadeddice.cc
Last active August 29, 2015 14:07
Draw a number [0...n) from a loaded dice (Vose's alias method)
//
// Draw a number [0...n) from a loaded dice (Vose's alias method)
//
#include <iostream>
#include <vector>
using namespace std;
unsigned int xor32() {
static unsigned long y = 2463534242UL;
@spaghetti-source
spaghetti-source / randomized_kd_tree.cc
Created November 12, 2014 02:50
Randomized KD Tree
//
// Randomized KD Tree (for d = 2)
//
// even split/join require O(n) time; however
// insert/remove require only O(log n) time.
//
#include <iostream>
#include <cstdio>
#include <complex>
@spaghetti-source
spaghetti-source / vanttage_point_tree.cc
Created November 16, 2014 11:17
Vantage Point Tree
//
// Vantage Point Tree (vp tree)
//
// each node has two childs, left and right;
// the left childs are closer than the threshold,
// and the right childs are farther than the thoreshold.
//
#include <iostream>
#include <vector>
#include <cstdio>
@spaghetti-source
spaghetti-source / dominance.cc
Created November 24, 2014 22:05
Dominance problems (red-blue dominance and colorless dominance)
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <unordered_map>
@spaghetti-source
spaghetti-source / network.tex
Created November 28, 2014 09:50
pgfplots network drawing sample
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc}
\usepackage{pgfplots}
\begin{document}
%%%
\tikzstyle{node}=[draw=black,circle,inner sep=0,minimum size=10]
\def \nodes {
1/-5/8.6,
@spaghetti-source
spaghetti-source / assignment.cc
Last active August 29, 2015 14:13
Jonker-Volgenant
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <unordered_map>