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
module F03 where | |
import Data.Ix (range) | |
import Data.List (sort) | |
import Data.Maybe (mapMaybe) | |
import Data.Tuple (swap) | |
type Index = (Int,Int) | |
type Omino = [Index] | |
type Moves = [Index] |
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
module E13 where | |
import Data.List | |
import Data.Maybe | |
type CubeCoord = (Int, Int, Int) | |
cubecoord :: Char -> Maybe CubeCoord | |
cubecoord 'a' = Just (0,0,0) | |
cubecoord 'b' = Just (1,-1,0) |
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
module F04 where | |
import Data.Bool (bool) | |
import Data.List (sort,unfoldr) | |
import Text.Printf (printf) | |
readDiag :: String -> Word | |
readDiag = read | |
toBin :: Word -> String |
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
module Main where | |
import System.IO.Unsafe | |
lazy :: IO a -> IO a | |
lazy = unsafeInterleaveIO | |
main :: IO () | |
main = do | |
{ input1 <- getLine |
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
module F05 where | |
import Control.Arrow (first, (&&&)) | |
import Data.Bool | |
import Data.List (sortBy,transpose,intercalate,isPrefixOf) | |
import Data.List.Split (splitOn) | |
import Data.Ord (comparing) | |
import Data.Tuple (swap) | |
rot :: ([String] -> [String], [String] -> [String]) -> [String] -> [String] |
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
poly00 :: Maybe a -> Maybe a | |
poly00 = \ ma -> case ma of | |
Nothing -> Nothing | |
Just x -> Nothing | |
poly01 :: Maybe a -> Maybe a | |
poly01 = \ ma -> case ma of | |
Nothing -> Nothing | |
Just !x -> Nothing |
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
type Score = Int | |
data Grade = A | B | C | D | |
instance Show Grade where | |
show A = "優" | |
show B = "良" | |
show C = "可" | |
show D = "不可" | |
grade :: Score -> Maybe Grade |
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
module F06 where | |
import Data.Map | |
import Data.Function (fix) | |
import Data.Function.YaMemo (Memo, memo) | |
ordering :: b -> b -> b -> Ordering -> b | |
ordering x _ _ LT = x | |
ordering _ y _ EQ = y | |
ordering _ _ z GT = z |
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
{-# LANGUAGE TupleSections #-} | |
module FizzBuzz where | |
import Data.Bool | |
{- | | |
>>> gFB (fizz.buzz) 1 | |
"1" | |
>>> gFB (fizz.buzz) 3 | |
"Fizz" |
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.Tree | |
data Lab = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
deriving (Eq,Ord,Enum,Bounded,Show,Read) | |
sample :: Tree Lab | |
sample = Node A [Node B [Node C [Node D [] | |
,Node E []] | |
,Node F [Node G [] | |
,Node H []]] |