Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / byoin.rb
Created November 2, 2017 20:08
Wikipedia日本語版「市区町村立病院」から病院名を取り出す
#!/usr/bin/env ruby
# Wikipedia日本語版「市区町村立病院」から病院名を取り出す
require "nokogiri"
require "open-uri"
filename = "byoin.html"
if !test(?f, filename)
html = open("https://ja.wikipedia.org/wiki/%E5%B8%82%E5%8C%BA%E7%94%BA%E6%9D%91%E7%AB%8B%E7%97%85%E9%99%A2").read
@takehiko
takehiko / kanji-by-kakusu.rb
Created January 2, 2018 23:44
Print kanji (Chinese characters) within 15 stroke counts
#!/usr/bin/env ruby
# kanji-by-kakusu.rb : print kanji (Chinese characters) within 15 stroke counts
# by takehikom
# 小学校で学習する15画以下の漢字をすべて出力する(他の画数,制限なしにも対応)
# 画数情報は,漢字辞典オンライン http://kanji.jitenon.jp/ にアクセスして取得
require "open-uri"
require "kconv"
@takehiko
takehiko / repeat3.rb
Created January 7, 2018 19:20
An inspector of a string that occurs three times successively, and generators
#!/usr/bin/env ruby
# repeat3.rb : an inspector of a string that occurs three times successively,
# and generators of a string which consists of "a" and "b"
# and has no substring that occurs three times successively
# by takehikom
module Repeat3
class Inspector
def initialize
@takehiko
takehiko / dominationgame.svg
Last active February 17, 2018 01:24
A domination game; you can click panels to change the color.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takehiko
takehiko / colorshow.c
Created April 28, 2018 07:07
colorshow.c
/*
* colorchow.c : ANSIエスケープシーケンスを利用して,
大文字を赤色,小文字を青色で表示する.
* 作成者: 村川猛彦 ([email protected])
* コンパイル方法: cc colorshow.c -o colorshow
* 実行方法: cat report1-cipher.txt | sed -e 'y/ABC/xyz/' | ./colorshow
*/
#include <stdio.h>
#include <ctype.h>
@takehiko
takehiko / trisub.rb
Created June 4, 2018 13:56
A solver of triangular subtraction problem
#!/usr/bin/env ruby
# trisub.rb : a solver of triangular subtraction problem
# by takehikom
# Usage:
# ruby trisub.rb
# ruby trisub.rb 4
# ruby trisub.rb 5
# ruby trisub.rb 6 # no answer
@takehiko
takehiko / inome-drawer.rb
Last active June 19, 2018 17:34
Drawing "inome", a traditional Japanese design in the shape of a heart
#!/usr/bin/env ruby
# inome-drawer.rb : drawing "inome", a traditional Japanese design in the shape of a heart
# by takehikom
# See also:
# http://shoujuin.boo.jp/?page_id=466
# http://d.hatena.ne.jp/takehikom/20180619/1529420399
class InomeDrawer
@takehiko
takehiko / icosa-drawer.rb
Created January 1, 2019 13:42
Drawing SVG images of a regular icosahedron with "kuku" forms along the sides
#!/usr/bin/env ruby
# icosa-drawer.rb : drawing SVG images of a regular icosahedron
# with "kuku" forms along the sides
# by takehikom
module IcosaDrawer
class Triangle
def initialize(param = {})
@label = param[:label]
@takehiko
takehiko / junjo-detector.rb
Created January 31, 2019 14:37
"Junjo" detector (designed for Order-of-Multiplication Dispute)
#!/usr/bin/env ruby
# junjo-detector.rb : 「かけ算の順序」(表記ゆれを含む)を見つける
# by takehikom
# ruby junjo-detector.rb
# ruby junjo-detector.rb file ...
# ruby junjo-detector.rb directory
def find_junjo(io, filename = nil)
@takehiko
takehiko / kukuniketa.rb
Last active March 11, 2019 09:54
Make 2-digit numbers that appear on the "kuku" table
#!/usr/bin/env ruby
# kukuniketa.rb : 「九九2桁」ソルバ
# by takehikom
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]といった配列を入力にとり,
# 2個ずつ組み合わせて2桁の数を作って,いずれも九九の答えに出現する
# ものを求める.
# see also: https://takehikom.hateblo.jp/entry/2019/03/11/054444