This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 白黒画像を透過画像に変換する --> | |
<body bgcolor="blue"> | |
<script> | |
let img=new Image; | |
img.src="hierarchy-000001.png"; | |
img.onload=()=>{ | |
let canvas=document.createElement("canvas"); | |
canvas.width=img.width; | |
canvas.height=img.height; | |
let ctx=canvas.getContext("2d"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Complex { | |
x: number; | |
y: number; | |
constructor(x: number, y: number) { | |
this.x = x; | |
this.y = y; | |
} | |
add(other: Complex) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sqrt(-1) in Q_5 | |
require "mathn" | |
def e_p_int(x, p) | |
e = 0 | |
while x % (p**e) == 0 | |
e += 1 | |
end | |
e - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir.glob("*.html").each do |fname| | |
str = File.read(fname) | |
if str !~ /<meta charset=/ | |
str = str.sub(/<head\b[^>]*>/) {|s| s + '<meta charset="utf-8">' } | |
File.write(fname, str) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://www.lysator.liu.se/c/ANSI-C-grammar-y.html */ | |
%token IDENTIFIER CONSTANT | |
%token LE_OP GE_OP EQ_OP NE_OP | |
%token INT | |
%token IF ELSE WHILE GOTO RETURN | |
%start translation_unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = <<EOS | |
0 _ _ R 0 | |
0 1 1 R 1 | |
1 _ 1 R 2 | |
1 1 1 R 1 | |
2 _ _ L 3 | |
2 1 1 R 2 | |
3 _ _ L 3 | |
3 1 _ L 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tape | |
def initialize | |
@array = [0] | |
@head = 0 | |
end | |
attr_accessor :array, :head | |
def read | |
@array[@head] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Babylonian method | |
def isqrt(n) | |
return 0 if n == 0 | |
s, t = 1, n | |
while s < t | |
s *= 2 | |
t /= 2 | |
end | |
begin | |
t = s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 関数プログラムのインタプリタ */ | |
/* すなわち,compはジャンププログラムのインタプリタだったが */ | |
/* これを第1章で定義される関数プログラムのインタプリタとして */ | |
/* 作ればどの程度複雑になるのか見てみる */ | |
int pair(int x, int y); | |
int ELM(int a, int i); | |
int length(int a); | |
int sequence(int a, int i); | |
int replace(int a, int i, int x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "set" | |
# 台集合xにおいてopensetsから生成される位相 | |
def gen_topology(x, opensets) | |
topo = Set[Set[], x] | |
topo.merge opensets | |
q = topo.to_a | |
while q.size > 0 | |
o = q.shift | |
topo.to_a.each do |o2| |