2011-06-28から1日間の記事一覧

10 進数を平衡三進数に変換する haskell ワンライナー: bt x = aux [] x where aux ts x = let (q, r, y, ts') = (div y 3, mod y 3, x + 1, r - 1 : ts) in if (0 == q) then ts' else aux ts' q

世の中に平衡三進数、あるいは対称三進数、英語で言えば balanced ternary というものがあると知ったのが昨日のこと。(「http://www.amazon.co.jp/gp/product/4622075482/ref=as_li_ss_tl?ie=UTF8&tag=ryohji-22&linkCode=as2&camp=247&creative=7399&creat…