This file contains 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 Control.Applicative ((<$>)) | |
import Data.List (nub, delete, subsequences, group, sort) | |
import System.Environment (getArgs) | |
import Test.HUnit | |
type Gem = Char | |
main :: IO () | |
main = do | |
princessPath <- (!! 0) <$> getArgs |
This file contains 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 Control.Applicative ((<$>)) | |
import Data.Char (ord) | |
main :: IO () | |
main = do | |
ws <- lines' <$> getContents | |
mapM_ putStrLn $ solve ws | |
solve :: [String] -> [String] | |
solve ws = do |
This file contains 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 Control.Applicative ((<$>)) | |
import Data.List (intersperse, sort, sortBy) | |
import Text.Parsec (char, digit, letter, many1, parse) | |
--| 日付はIntとして持つ | |
-- 1と10の位が日, 100と1000の位が月に相当する | |
-- e.g., 1月 5日 -> 105 | |
-- 12月30日 -> 1230 | |
data Ticket = Ticket { tName :: String | |
, tFrom :: Int |
This file contains 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.Bits | |
import Data.List | |
binStr :: Bits a => a -> String | |
binStr n = foldl' f "" $ take (bitSize n) [0..] | |
where | |
f str i | |
| testBit n i = '1' : str | |
| otherwise = '0' : str |
This file contains 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 Numeric | |
import Data.Char | |
import Control.Monad | |
import Control.Applicative hiding (many, (<|>)) | |
import Text.Parsec | |
import Text.Parsec.String | |
data LLVal = IPv4 | IPv6 | MAC | Etc | |
deriving (Show, Eq) |
This file contains 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
<?php | |
$hostname = '192.168.0.100'; | |
$port = 80; | |
$timeout = 10; | |
$sock = fsockopen($hostname, $port, $errono, $errstr, $timeout); | |
if ($sock === false) { | |
exit("{$errstr} ({$errono})\n"); | |
} | |
echo "connect {$hostname}:{$port}\n"; |
This file contains 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 System.Random | |
import System.Time | |
import Control.Monad.State | |
main :: IO () | |
main = do | |
seed <- mkSeed | |
talk $ iSaid seed | |
mkSeed :: IO Int |
This file contains 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 | |
import Test.QuickCheck | |
bubbleSort :: Ord a => [a] -> [a] | |
bubbleSort [] = [] | |
bubbleSort [x] = [x] | |
bubbleSort xs = bubbleSort zs ++ z | |
where | |
(zs, z) = splitAt (length xs - 1) $ bubble xs | |
bubble (y0:y1:ys) |
This file contains 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 | |
import Test.QuickCheck | |
combSort :: Ord a => [a] -> [a] | |
combSort xs = comb (gap (length xs)) xs | |
comb :: Ord a => Int -> [a] -> [a] | |
comb h xs | |
| h <= 0 = xs | |
| h == 1 = let sorted = comb' in |
This file contains 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 | |
import Test.QuickCheck | |
mergeSort :: (Ord a) => [a] -> [a] | |
mergeSort [] = [] | |
mergeSort [x] = [x] | |
mergeSort items = merge l' r' | |
where | |
(l, r) = halve items | |
l' = mergeSort l |
OlderNewer