Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List
- --shift String left
- rl::[String]->[String]
- rl (x:xs) = xs++[x]
- --shift string right
- rr::[String]->[String]
- rr (x:xs) = (take 1 (reverse xs))++x:init xs
- --extract char string from a column
- ms::Int->Int->[[String]]->[Char]
- ms z y (x:xs) = map (!!y) (map (!!z) (x:xs))
- --print cube
- pc::[[String]]->String
- pc (x:xs) = t++"\n"++m++"\n"++b
- where t = (unwords x)
- m = (unwords (xs!!0))
- b = (unwords (xs!!1))
- --top down representation of top and bottom sides of cube
- td= [["www"],
- ["www"],
- ["www"]]
- --side to side representation of cube
- ss = [["bbb","def","ghi","jjj"],
- ["bbb","def","ghi","jjj"],
- ["bbb","def","ghi","jjj"]]
- bt = [["yyy"],
- ["yyy"],
- ["yyy"]]
- --extract row as string
- er::Int->([[String]],[[String]])->String
- er z (x,y) = unwords (snd((x,y))!!z)
- --insert row as string )
- ir::Int->[String]->([[String]],[[String]])->[[String]]
- ir 0 nr (x,y) = nr:s
- where s = snd (x,y)
- ir 1 nr (x,y) = [head s]++[nr]++tail s
- where s = snd (x,y)
- ir 2 nr (x,y) = (tail s)++[nr]
- where s = snd (x,y)
- cube = (td,ss)
- main = putStr(pc(ir 2 ["yes","hh"] cube))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement