Haskell
http://qiita.com/Nabetani/items/ad47666c2f2f44ada1e7
http://nabetani.sakura.ne.jp/hena/ord18notfork/
module Main where
main = do
let order = "42873x.3."
print order
data Customer = Normal | Claimer deriving (Eq, Show)
type Line = [Customer]
checkers :: [Int]
checkers = [2,7,3,5,2]
regist :: [Line] -> [Line]
regist lines = map regist' $ zip [0..] lines where
regist' nl = dropNormal (checkers !! regidx) line where
(regidx, line) = nl
dropNormal 0 l = l
dropNormal n l@(c:cs) = case c of
Normal -> dropNormal (n-1) cs
Claimer -> l
timeElapsed :: String -> [Line]
timeElapsed cs = timeElapsed' cs [] where
timeElapsed' (c:cs) lines = case c of
'.' -> timeElapsed' cs $ regist lines
'x' -> timeElapsed' cs $ lineup 1 Claimer lines
otherwise -> timeElapsed' cs $ lineup (read [c]) Normal lines
lineup :: Int -> Customer -> [Line] -> [Line]
lineup n customer ls = lineup' (replicate n customer) ls where
lineup' cs ls = undefined
lineup' で詰まった..orz