[ create a new paste ] login | about

Link: http://codepad.org/ANR1mjIq    [ raw code | output | fork ]

Haskell, pasted on Dec 29:
import Text.Printf
import Data.Char
import System.Random

clock :: String
clock = unlines
        [ "         0"
        , "    b         1"
        , ""
        , " a               2"
        , ""
        , "9                 3"
        , ""
        , " 8               4"
        , ""
        , "    7         5"
        , "         6"]

dac :: String -> String
dac str = map f clock
    where
      f c | c == hc = 'X'
          | c == mc = 'x'
          | ord c > 47 = 'o'
          | otherwise = c
      (h, m) = let (hs, (_:ms)) = span (/=':') str in (read hs, read ms)
      hc = intToDigit $ h `mod` 12
      mc = let (d, a) = m `divMod` 5 in intToDigit $ if a < 3 then d else d + 1

main :: IO ()
main = mapM_ (putStrLn . f) . (["18:35","00:00","10:03"] ++) =<< makeInput 7
    where
      f s = "input\n" ++ s ++ "\noutput\n" ++ dac s

makeInput :: Int -> IO [String]
makeInput i = do
    hs <- randomRs (0,23) `fmap` newStdGen
    ms <- randomRs (0,59) `fmap` newStdGen
    return $ take i $ zipWith (\x y -> printf "%02d:%02d" (x::Int) (y::Int)) hs ms


Output:
input
18:35
output
         o
    o         o

 o               o

o                 o

 o               o

    x         o
         X

input
00:00
output
         X
    o         o

 o               o

o                 o

 o               o

    o         o
         o

input
10:03
output
         o
    o         x

 X               o

o                 o

 o               o

    o         o
         o

input
00:43
output
         X
    o         o

 o               o

x                 o

 o               o

    o         o
         o

input
12:48
output
         X
    o         o

 x               o

o                 o

 o               o

    o         o
         o

input
19:17
output
         o
    o         o

 o               o

o                 x

 o               o

    X         o
         o

input
18:30
output
         o
    o         o

 o               o

o                 o

 o               o

    o         o
         X

input
10:09
output
         o
    o         o

 X               x

o                 o

 o               o

    o         o
         o

input
12:42
output
         X
    o         o

 o               o

o                 o

 x               o

    o         o
         o

input
23:24
output
         o
    X         o

 o               o

o                 o

 o               o

    o         x
         o



Create a new paste based on this one


Comments: