This file contains hidden or 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
| import Data.List (maximumBy) | |
| import Data.Function (on) | |
| collatzLength :: Int -> Int -> Int | |
| collatzLength acc 1 = acc | |
| collatzLength acc n | |
| | even n = collatzLength (acc+1) (n `div` 2) | |
| | odd n = collatzLength (acc+1) (3*n + 1) | |
| -- 末尾再帰にしたら少し早くなった |
This file contains hidden or 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
| import Data.Char(digitToInt) | |
| main = print $ sum $ map digitToInt $ show $ 2^1000 | |
| -- 1366 | |
| -- 多倍長整数チート感ある… |
This file contains hidden or 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
| puts (2**1000).to_s.chars.map{|c|c.to_i}.inject :+ |
This file contains hidden or 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
| function! s:is_leap_year(year) | |
| return a:year % 4 == 0 && !(a:year % 100 == 0 && a:year % 400) ? 1 : 0 | |
| endfunction | |
| function! s:count_20th_century_mondays() | |
| let l:day_count = 366 " 1900年の365日分 + 1 | |
| let l:monday = 0 | |
| " 1 2 3 4 5 6 7 8 9 10 11 12 | |
| let month = [31,28,31,30,31,30,31,31,30,31,30,31] | |
| for y in range(1901,2000) |
This file contains hidden or 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
| import Data.Char (digitToInt) | |
| main :: IO () | |
| main = print $ sum $ map digitToInt $ show $ product [1..100] | |
| -- 648 |
This file contains hidden or 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
| snippet constexpr_func | |
| abbr constexpr auto func() -> decltype | |
| prev_word '^' | |
| constexpr auto ${1:name}( ${2:args} ) -> decltype($1) | |
| { | |
| return ${1:body}; | |
| } |
This file contains hidden or 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
| #include <iostream> | |
| #include <vector> | |
| // range-based アルゴリズム使いたかった | |
| #include <boost/range/algorithm.hpp> | |
| #include <boost/range/algorithm_ext.hpp> | |
| #include <boost/range/numeric.hpp> | |
| inline int sum_of_divisors(int const n) | |
| { |
This file contains hidden or 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
| main :: IO () | |
| main = print $ sum $ scanl1 (+) $ 1:(concat $ map (replicate 4) [2,4..1000]) | |
| -- 669171001 |
This file contains hidden or 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
| " フレームにアイコンを表示 | |
| let g:tweetvim_display_icon = 1 | |
| " 1ページのツイート数 | |
| let g:tweetvim_tweet_per_page = 60 | |
| nnoremap <silent><Leader>tw :<C-u>tabnew <Bar> TweetVimHomeTimeline<CR> | |
| nnoremap <silent><Leader>tl :<C-u>TweetVimHomeTimeline<CR> | |
| nnoremap <silent><Leader>tm :<C-u>TweetVimMentions<CR> | |
| nnoremap <Leader>ts :<C-u>TweetVimSay<CR> |
This file contains hidden or 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
| " This is イヌゥ… script for vim's status line. | |
| " The original script is here. | |
| " https://github.com/koron/homoo-vim | |
| " All you have to do is to execute the below command. | |
| " :source path/to/inuu.vim | |
| scriptencoding utf-8 |