Skip to content

Instantly share code, notes, and snippets.

View butchi's full-sized avatar

IWABUCHI Yu(u)ki (butchi) butchi

View GitHub Profile
@butchi
butchi / YukiCoder89.nb
Created October 21, 2014 15:42
yukicoder No. 47 ポケットを叩くとビスケットが2倍
(* http://yukicoder.me/problems/no/47 *)
ans[n_] := Ceiling[Log[2, n]]
@butchi
butchi / YukiCoder80.nb
Last active August 29, 2015 14:08
yukicoder No.53 悪の漸化式
(* http://yukicoder.me/problems/no/53 *)
a[k_] := 3^k/4^(k - 1)
N[a[100]]
@butchi
butchi / YukiCoder80_2.nb
Created October 30, 2014 16:23
yukicoder No.53 悪の漸化式
(* http://yukicoder.me/problems/no/53 *)
N[RecurrenceTable[{4 a[k] == 19 a[k - 1] - 12 a[k - 2], a[0] == 4, a[1] == 3}, a, {k, 0, 100}]]
@butchi
butchi / yukicoder83.nb
Created November 2, 2014 16:57
No.55 正方形を描くだけの簡単なお仕事です。
(* http://yukicoder.me/problems/no/55 *)
pLi = Complex[#[[1]], #[[2]]] & /@
Partition[ImportString["8 10 14 14 13 9", "Table"][[1]], 2];
dLi = Abs[RotateLeft[pLi, 1] - RotateLeft[pLi, 2]];
permLi = Permutations[pLi];
p4Li = (#[[2]] + I (#[[1]] - #[[3]])) & /@ permLi;
sqLi = Table[Append[permLi[[n]], p4Li[[n]]], {n, 1, Length[permLi]}];
edgeLen[pLi_] := Abs[pLi - RotateLeft[pLi]];
judgeLi = SameQ @@ # & /@ (edgeLen /@ sqLi);
pos = Position[judgeLi, True];
@butchi
butchi / file0.html
Last active August 29, 2015 14:09
要素からコメントアウトを取り出す ref: http://qiita.com/butchi_y/items/78ef939cbcef4f108c66
<!DOCTYPE html>
<html>
<head></head>
<body>
<!--hoge-->
foo
<!--piyo-->
bar
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
</body>
@butchi
butchi / YukiCoder158.nb
Last active August 29, 2015 14:11
No.106 素数が嫌い!2
(* http://yukicoder.me/problems/no/106 *)
(* TLEで失敗しました。 *)
f[n_, k_] := Length[Select[Table[Length[FactorInteger[m]], {m, 2, n}], # >= k &]]
f[2, 1]
f[4, 2]
f[1000, 4]
@butchi
butchi / q-1.js
Created December 22, 2014 14:00
window.Objectのfalseのようなtrueの話 ref: http://qiita.com/butchi_y/items/0167ff91124c2f9bea2d
({}) !== ({}); // == ?
@butchi
butchi / file0.js
Last active August 29, 2015 14:18
"+"を使わないプログラミング ref: http://qiita.com/butchi_y/items/3c3e9de3258c6a22ecd0
function plus(x, y) {
return x + y;
}
ans = plus(5, 3);
console.log(ans); // => 8
@butchi
butchi / file0.txt
Last active August 29, 2015 14:18
Wikipedia項目から四字熟語の抽出 ref: http://qiita.com/butchi_y/items/b31ee2b9480546b43f0b
一_(緑茶飲料)
一_茶花
一〇〇式
一〇〇式三十七粍戦車砲
...
龜山鄉
龜田鵬齋