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
" eregexプラグイン用に、 1,$s/ → 1,$S/ に変換 g/ → G/ に変換 | |
" Based on: https://twitter.com/koturn/status/843830301780406272 | |
" https://gist.github.com/hyuki0000/45189cb5e188ef42c8ca0925cd3acf95 | |
cnoremap <expr>/ ReplaceSlash() | |
function ReplaceSlash() | |
if getcmdtype() ==# ':' | |
if getcmdline() ==# '1,$s' | |
call feedkeys("\<C-u>1,$S/", 'n') | |
return | |
elseif getcmdline() ==# 'g' |
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
# 奥村晴彦他『Javaによるアルゴリズム事典』p.290をRubyで | |
def sqrt(n) | |
r = n | |
t = 0 | |
while t != r do | |
t = r | |
r = (n / r + r) / 2 | |
end | |
r |
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
def sqrtn(s) | |
a = 0 | |
p = 0 | |
while not (0 <= (s / 10**p) and (s / 10**p) < 100) do | |
p += 2 | |
end | |
while p >= 0 | |
b = 9 | |
while (s / 10**p) < b * (20 * a + b) do | |
b -= 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
open "file.txt" do |f| | |
while !f.eof? do | |
l = f.readline | |
break unless l | |
puts "#{l.length}" | |
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
# based on shattered.io | |
open("1.dat", "w") do |f| | |
f.print "\x25\x50\x44\x46\x2d\x31\x2e\x33\x0a\x25\xe2\xe3\xcf\xd3\x0a\x0a\x0a\x31\x20\x30\x20\x6f\x62\x6a\x0a\x3c\x3c\x2f\x57\x69\x64\x74\x68\x20\x32\x20\x30\x20\x52\x2f\x48\x65\x69\x67\x68\x74\x20\x33\x20\x30\x20\x52\x2f\x54\x79\x70\x65\x20\x34\x20\x30\x20\x52\x2f\x53\x75\x62\x74\x79\x70\x65\x20\x35\x20\x30\x20\x52\x2f\x46\x69\x6c\x74\x65\x72\x20\x36\x20\x30\x20\x52\x2f\x43\x6f\x6c\x6f\x72\x53\x70\x61\x63\x65\x20\x37\x20\x30\x20\x52\x2f\x4c\x65\x6e\x67\x74\x68\x20\x38\x20\x30\x20\x52\x2f\x42\x69\x74\x73\x50\x65\x72\x43\x6f\x6d\x70\x6f\x6e\x65\x6e\x74\x20\x38\x3e\x3e\x0a\x73\x74\x72\x65\x61\x6d\x0a\xff\xd8\xff\xfe\x00\x24\x53\x48\x41\x2d\x31\x20\x69\x73\x20\x64\x65\x61\x64\x21\x21\x21\x21\x21\x85\x2f\xec\x09\x23\x39\x75\x9c\x39\xb1\xa1\xc6\x3c\x4c\x97\xe1\xff\xfe\x01\x73\x46\xdc\x91\x66\xb6\x7e\x11\x8f\x02\x9a\xb6\x21\xb2\x56\x0f\xf9\xca\x67\xcc\xa8\xc7\xf8\x5b\xa8\x4c\x79\x03\x0c\x2b\x3d\xe2\x18\xf8\x6d\xb3\xa9\x09\x01\xd5\xdf\x45\xc1\x4f\x26\xfe\xdf\xb3\xd |
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
\documentclass[dvipdfmx]{jsbook} | |
\usepackage{lmodern} | |
\usepackage{pxrubrica} % http://qiita.com/zr_tex8r/items/42466cbcbeb670a3a2dc | |
% \usepackage{ccfonts} % ccfonts を入れると、sin, cosだけじゃなくすべての英文がConcreteになってしまうので注意 | |
% \usepackage[euler-digits]{eulervm} | |
\usepackage[T1]{fontenc} | |
\usepackage{textcomp} | |
\usepackage[utf8]{inputenc} | |
\usepackage{amsmath,amssymb} | |
\pagestyle{empty} |
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
\documentclass[dvipdfmx]{jsbook} | |
\usepackage{lmodern} | |
\usepackage{ccfonts} % ccfonts を入れると、sin, cosだけじゃなくすべての英文がConcreteになってしまうので注意 | |
\usepackage[euler-digits]{eulervm} | |
\usepackage[T1]{fontenc} | |
\usepackage{textcomp} | |
\usepackage[utf8]{inputenc} | |
\usepackage{amsmath,amssymb} | |
\pagestyle{empty} | |
\begin{document} |
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
# Making A Babylonian-like Reciprocal Table (1..100) | |
# 1..100 の逆数表をバビロニア風に作る | |
# ただし、無限小数になるものは ... を付加する | |
# https://cakes.mu/posts/15267 | |
def inv60(n) | |
a = [] | |
m = 1 | |
loop do | |
x = (60 * m) / n |
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
def f(n,m) | |
if n == 0 | |
1 | |
else | |
m * f(n-1,m) | |
end | |
end | |
puts "f(2,2) = #{f(2,2)}" | |
puts "f(10,2) = #{f(10,2)}" |