Skip to content

Instantly share code, notes, and snippets.

View spaghetti-source's full-sized avatar

Takanori MAEHARA spaghetti-source

View GitHub Profile
const {BskyAgent, RichText, AppBskyFeedPost} = require("@atproto/api")
let Parser = require('rss-parser')
let parser = new Parser()
const entities = require("entities");
const sleep = (waitTimeInMs) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));
const settings = [
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
node(sendai;ishinomaki;shiogama;kesennuma;shiroishi;natori;kakuda;tagajyo;iwanuma;tome;kurihara;higashimatsushima;oosaki;zaou;shichikasyuku;oogawara;murata;shibata;kawasaki;marumori;watari;yamamoto;matsushima;shichigahama;rifu;taiwa;oosato;tomiya;oohira;shikama;kami;wakuya;misato;onagawa;minamisanriku).
edge(sendai,natori). edge(sendai,tagajyo). edge(sendai,tomiya). edge(sendai, murata). edge(sendai, kawasaki). edge(sendai, shichigahama). edge(sendai, rifu). edge(sendai, taiwa). edge(sendai, shiki).
edge(ishinomaki, tome). edge(ishinomaki, higashimatsushima). edge(ishinomaki, wakuya). edge(ishinomaki, misato). edge(ishinomaki, onagawa). edge(ishinomaki, minamisanriku).
edge(shiogama, tagajyo). edge(shiogama, shichigahama). edge(shiogama, rifu).
edge(kesennuma, tome). edge(kesennuma, minamisanriku).
edge(shiroishi, kakuda). edge(shiroishi, zaou). edge(shiroishi, shichikasyuku). edge(shiroishi, oogawara). edge(shiroishi, marumori).
edge(natori, sendai). edge(natori, kesennuma). edge(natori, murata).
edge(kaku
@spaghetti-source
spaghetti-source / bentley-ottman.cc
Created December 29, 2017 00:40
Bentley-Ottman Segment Intersection O((n+k) log n)
#include <iostream>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <cassert>
#include <queue>
#include <set>
@spaghetti-source
spaghetti-source / branch_bound_HK.cc
Created February 8, 2015 04:10
TSP branch bound with Held-Karp lower bound
//
// Held and Karp bound
//
// T が 1-tree iff T は {2,...,n} 上の全域木 + 1 から枝が 2 本.
// 1-tree かつ全部の頂点の誘導次数が 2 であればそれはサイクル.
//
// 巡回セールス人を
// minimize c(T)
// subject to T is a 1-tree
// deg_T(i) = 2 for all i
@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>
@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 / 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 / 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 / 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>