Skip to content

Instantly share code, notes, and snippets.

$1$ から $n$ ($n > 2$) の $n$ 個の連続した自然数を CSV のようにカンマ区切りで文字列にした際の文字数 len_seq$n$ で表現してください。

自然数 $n$ の桁数は

$$\mathit{digit}(n) = \lfloor \log_{10} (n) \rfloor + 1$$

で求められる。

import Data.List (inits)
-- [[],[0],[1],[0,0],[0,1],[1,0],[1,1],[0,0,0],[0,0,1],[0,1,0]]
main :: IO ()
main = print $ take 10 bits
bits :: [[Int]]
bits = concatMap sequence $ inits $ repeat [0, 1]

Git のワークフロー

Git で開発を管理するいくつかのワークフローを模式図で比較する。

図以外は上位互換な記事を見つけてしまった: 4 branching workflows for Git

GitHub flow

シンプルなやつ。これになりたい。 master ブランチはすぐリリースされることが前提になっている。

@cohei
cohei / death_march.md
Last active May 16, 2018 17:03 — forked from voluntas/death_march.md
デスマーチが起きる理由 - 3つの指標

デスマーチが起きる理由 - 3つの指標

著者: 青い鴉(ぶるくろ)さん @bluecrow2

これは結城浩さんの運用されていた YukiWiki に当時 Coffee 様 (青い鴉(ぶるくろ)さん)がかかれていた文章です。 ただ 2018 年 3 月 7 日に YukiWiki が運用停止したため消えてしまったため、その記事のバックアップです。

今は 404 ですが、もともとの記事の URL は http://www.hyuki.com/yukiwiki/wiki.cgi?%A5%C7%A5%B9%A5%DE%A1%BC%A5%C1%A4%AC%B5%AF%A4%AD%A4%EB%CD%FD%CD%B3 になります。

昔、自分がとても感銘を受けた文章なので、このまま読めなくなるのはとてももったいないと思い、バックアップとして公開しています。

@cohei
cohei / Q2357.hs
Created November 2, 2017 06:45 — forked from naohaq/Q2357.hs
An extension field of ℚ
{- -*- coding: utf-8-unix -*- -}
module Q2357
( ExtR2(..)
, ExtR3(..)
, ExtR5(..)
, ExtR7(..)
, Q2357
, factor
, root2
@cohei
cohei / eru.hs
Last active September 15, 2016 07:30
千反田える http://blog.hiyamugi.net/2012/10/31/0001 より。漢数字などはサボった。
#!/usr/bin/env stack
-- stack runghc --install-ghc --resolver=lts-7.0
data Tanda = Tanda Int Char
instance Show Tanda where
show (Tanda i c) = show i ++ "反田" ++ [c]
next :: Tanda -> Tanda
next (Tanda i c) = Tanda (succ i) (if c == 'Z' then 'A' else succ c)
import Control.Arrow (first)
import Control.Concurrent (threadDelay)
import Control.Monad (forM_, replicateM)
import Data.List (isSuffixOf, inits)
import System.Environment (getArgs)
import System.Random (Random(random, randomR, randoms), newStdGen)
main :: IO ()
main = do
args <- getArgs
@cohei
cohei / aho.txt
Created May 3, 2015 18:38
3のつく数字と3の倍数でアホになる
ghcによるアホ率の計算
10^1 0.3
10^2 0.45
10^3 0.513
10^4 0.5625
10^5 0.60633
10^6 0.645705
10^7 0.6811353
10^8 0.71302185
10^9 0.741719673
@cohei
cohei / auto-install-dotfiles.md
Last active July 29, 2020 04:20
ドットファイルを GitHub に置き、インストールを自動化した話

ドットファイル、ご存じでしょうか。 UNIX 系のシステムの、主にホームディレクトリにある . (ドット) から始まる名前の設定ファイルのことをいいます。 .bashrc とか .emacs.d/ とかありますよね。だんだん手になじむ設定がたまってきて、複数の環境で使い回したくなってくるわけです。そこで、ドットファイルを GitHub に置いている人をよく見かけます。

私も置いています。何もしなければ、各環境でこのレポジトリをクローンしてシンボリックリンクを張ったりするわけです。めんどくさいですね。

そこで、今日のネタは install.sh です。このようなスクリプトを書いておけば、

curl https://raw.githubusercontent.com/cohei/dotfiles/master/install.sh | bash
def distribute(n, xs)
xs.each_slice(n).map { |array| l = array.length ; array + [nil]*(n-l) }.transpose.map(&:compact)
end
distribute(3, (1..7)) #=> [[1, 4, 7], [2, 5], [3, 6]]