-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
45 lines (40 loc) · 1.08 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Main where
import Rotations
import Solving
import System.Environment
import Types
import Utils
import Prelude hiding (Left, Right)
main :: IO ()
main = do
args <- getArgs
let fileName = head args
content <- readFile fileName
let fileLines = lines content
let cube = readCube fileLines []
let solved = solveCube cube
print (fst solved)
print (snd solved)
readCube :: [String] -> Cube -> Cube
readCube [] cube = cube
readCube (x : xs) cube =
let w = words x
in let side = head w
in let currentCube = ((translateSide side, map translateColor (tail w)) :: Face) : cube
in readCube xs currentCube
translateSide :: String -> Side
translateSide "Down" = Down
translateSide "Up" = Up
translateSide "Left" = Left
translateSide "Right" = Right
translateSide "Front" = Front
translateSide "Back" = Back
translateSide _ = Up
translateColor :: String -> Color
translateColor "Blue" = Blue
translateColor "Red" = Red
translateColor "Yellow" = Yellow
translateColor "White" = White
translateColor "Orange" = Orange
translateColor "Green" = Green
translateColor _ = White