Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / tatami.rb
Created May 7, 2015 21:07
A solver of tatami mat arrangement problem
#!/usr/bin/env ruby
# tatami.rb : A solver of tatami mat arrangement problem
# by takehikom
module Tatami
class Arranger
def initialize(w = 4, h = 4, opt = {})
@width = w
@height = h
@takehiko
takehiko / n-win-m-match.rb
Created May 19, 2015 12:00
Winning ratios
#!/usr/bin/env ruby
# n-win-m-match.rb : じゃんけんをm回やって,そのうちn回以上勝つ確率
# by takehikom
require "rational"
class NWinMMatch
def initialize(opt = {})
@choose = {} # 2項係数
@takehiko
takehiko / kanatrie.rb
Created August 13, 2015 22:34
Romanization Rule into Trie
#!/usr/bin/env ruby
# kanatrie.rb : ローマ字の綴りをトライ木に(ヘボン式・訓令式・日本式に対応)
# by takehikom
# required: KAKASI, Graphviz
def create_romaji_kana_hash(option = {})
if option[:label]
puts "==== #{option[:label]} ===="
@takehiko
takehiko / gfload.rb
Created October 15, 2015 20:30
Load Calculator for Gymnastic Formation
#!/usr/bin/env ruby
# gfload.rb : Load Calculator for Gymnastic Formation
# by takehikom
require 'optparse'
module GFLoad
module Helper
SEPARATOR = "."
@takehiko
takehiko / gfload+.rb
Last active October 16, 2015 21:19
Load Estimation of Trigonal Human Pyramids
#!/usr/bin/env ruby
# gfload+.rb : Load Estimation of Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151016/1444941800
# http://d.hatena.ne.jp/takehikom/20151018/1445094000
require_relative "gfload.rb"
@takehiko
takehiko / gfload_est.rb
Last active October 18, 2015 17:07
Load Estimator of Trigonal Human Pyramids
#!/usr/bin/env ruby
# gfload_est.rb - Load Estimator of Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151019/1445266799
# usage:
# ruby gfload_est.rb
# ruby gfload_est.rb -p 7 -m 0
@takehiko
takehiko / gf_build.rb
Last active October 18, 2015 17:06
How to Build Trigonal Human Pyramids
#!/usr/bin/env ruby
# gf_build.rb - How to Build Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151020/1445266800
# usage:
# ruby gf_build.rb
# ruby gf_build.rb -p 11
@takehiko
takehiko / aozora-picker.rb
Created October 23, 2015 21:17
Intro Extractor for Articles in Aozora Bunko
#!/usr/bin/env ruby
# aozora-picker.rb : 青空文庫収録作品のイントロ収集
# by takehikom
# usage:
# ruby aozora-picker.rb
# ruby aozora-picker.rb wa
# ruby aozora-picker.rb /path/to/github/aozorabunko/index_pages/sakuhin_wa?.html
# see also:
# http://www.aozora.gr.jp/
@takehiko
takehiko / compare-pi.rb
Created December 4, 2015 20:29
Find nearest substring of your number from pi
#!/usr/bin/env ruby
# compare-pi.rb : Find nearest substring of your number from pi
# by takehikom
require "net/http"
require "uri"
require "kconv"
module ComparePI
@takehiko
takehiko / catree.rb
Last active January 23, 2016 14:56
Applying commutative and associative laws to syntax trees
#!/usr/bin/env ruby
# catree.rb : applying commutative and associative laws to syntax trees
# by takehikom
module CATree
class Manager
def initialize(size = 4)
@factor_size = size
setup_node