magitの使い方の動画

magitの使い方の動画を作ってみました

magitのインストール

branchの作成

ファイルを編集してコミットする

差分の取り消し その1 全部取り消す
[

差分の取り消し その2 ファイル単位で取り消す

差分の取り消し その3 hunk単位で取り消す

リセットする

作業ブランチでの修正が完了したのでマージする

間違ってmasterでコミットしたものを作業ブランチにする

間違ってmasterでコミットしたものを作業ブランチにcherry-pick

リモートブランチにpushします

Project 26

p26 :: Integer -> Integer
p26 n = p26_length 1 (div_2_5 n)
  where 
    div_2_5 :: Integer -> Integer
    div_2_5 n
      | rem n 2 == 0 = div_2_5 (div n 2)
      | rem n 5 == 0 = div_2_5 (div n 5)
      | otherwise = n
    p26_length :: Integer -> Integer -> Integer
    p26_length len x
      | rem d x == 0 = 0
      | rem d x == 1 = len
      | otherwise = p26_length (len+1) x
      where d = product $ take (fromIntegral len) $ repeat 10

fst $ maximumBy (\a b -> (compare (snd a) (snd b))) $ map (\x -> (x, p26 x)) [1..1000]

Problem 24

p24 :: [a] -> Int -> [a]
p24 [] _ = []
p24 [x] 0 = [x]
p24 list nth = x : p24 next_list remain
  where len = length list
        p = product [1..(len-1)]
        (q, remain) = divMod nth p
        (x, next_list) = p24' list q
        p24' list n = (x, remain)
          where x = last $ take (n+1) list
                remain = (take n list) ++ (reverse $ take (length list - n - 1) $ reverse list)

concat $ map show $ p24 [0..9] (1000000-1)