Skip to content

Instantly share code, notes, and snippets.

View joker1007's full-sized avatar

Tomohiro Hashidate joker1007

View GitHub Profile
@joker1007
joker1007 / file0.sh
Created August 8, 2012 08:23
git rebase -i "HEAD~N"を打ちやすくする ref: http://qiita.com/items/214a99063b696a458013
function grbi() {
if [ "$1" -gt 0 ]; then
git rebase -i "HEAD~${1}"
else
echo "Using: grbi n\n (n is number greater then 0)"
fi
}
@joker1007
joker1007 / solve_route.hs
Created August 14, 2012 12:02
すごいH本 Chapter 10.2
import Data.List
import Control.Monad
data Section = Section {getA :: Int, getB :: Int, getC :: Int} deriving Show
pathData :: [[Int]]
pathData = [[50,10,30],[5,90,20],[40,2,25],[10,8,0]]
makeSections :: [Section]
makeSections = foldr (\(a:b:c:[]) sections -> Section a b c : sections) [] pathData
@joker1007
joker1007 / poker.hs
Created August 21, 2012 11:58
ポーカーの役を検出する。 http://qiita.com/items/cbc3af152ee3f50a822f
import Data.List
import System.Environment
test :: String
test = "D3C3C10D10S3"
test2 :: String
test2 = "D3C3C10D10S4"
test3 :: String
@joker1007
joker1007 / Heap.hs
Created August 27, 2012 12:44
素振りのために、ヒープを実装してみた。
module Heap (Heap(Empty, Node), getValue, insert, pop, fromList) where
import Prelude hiding (foldl, foldr)
import Data.Foldable
import Data.Monoid
data Heap a = Empty | Node (Heap a) a (Heap a)
instance (Show a) => Show (Heap a) where
show Empty = "E"
@joker1007
joker1007 / doukaku3.hs
Created September 4, 2012 13:16
Haskellで書いてみた -> オフラインリアルタイムどう書く第三回の参考問題 http://qiita.com/items/ebd8a56b41711ba459f9
import Control.Monad.State
import Control.Monad.Writer
import System.Environment
import Data.List
type Result = (Int, Int, Int)
showResult :: Result -> String
showResult (o, s, b) = show o ++ show s ++ show b
import Prelude hiding (lookup)
import Data.List hiding (lookup)
import Data.Maybe
import Data.Map
import Control.Monad.RWS
import System.Environment
data Node = A | B | C | D | E | F deriving (Show, Eq, Ord, Enum)
data Path = Path {source :: Node, target :: Node} deriving Show
@joker1007
joker1007 / yokohena20120907.hs
Created September 9, 2012 07:22
第3回 オフラインリアルタイムどう書く解答 http://nabetani.sakura.ne.jp/hena/ord3ynode/
import Control.Monad.RWS
import System.Environment
data Node = A | B | C | D | E | F deriving (Show, Eq, Ord, Enum)
data Path = Path {source :: Node, target :: Node} deriving Show
data NodeGroup = NG Node Node Node Node deriving Show
route :: Path -> Char -> Node
require "bundler/setup"
require "pattern-match"
require "pp"
class Tree
class Node
attr_accessor :value, :left, :right
include PatternMatch::Deconstructable
require "rubygems"
require "bundler/setup"
require "tapp"
class Regexp
def self.build(*numbers)
nums = []
numbers.each do |num|
if num.is_a? Range
nums.concat(num.to_a)
import Data.List
import Control.Monad.Writer
import System.Environment
testSource :: [Int]
testSource = [100, 5, 5, 2, 6, 8]
testTarget :: Int
testTarget = 522