diff options
Diffstat (limited to '.stack-work/intero')
47 files changed, 0 insertions, 1144 deletions
diff --git a/.stack-work/intero/intero-script15638LtG b/.stack-work/intero/intero-script15638LtG deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script15638LtG +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script18425zvS b/.stack-work/intero/intero-script18425zvS deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script18425zvS +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script21871YJc b/.stack-work/intero/intero-script21871YJc deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script21871YJc +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script250346te b/.stack-work/intero/intero-script250346te deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script250346te +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034H4k b/.stack-work/intero/intero-script25034H4k deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034H4k +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034UCr b/.stack-work/intero/intero-script25034UCr deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034UCr +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034UQT b/.stack-work/intero/intero-script25034UQT deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034UQT +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034gZS b/.stack-work/intero/intero-script25034gZS deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034gZS +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034haZ b/.stack-work/intero/intero-script25034haZ deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034haZ +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script25034tjY b/.stack-work/intero/intero-script25034tjY deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script25034tjY +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script265874pa b/.stack-work/intero/intero-script265874pa deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script265874pa +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script26587REU b/.stack-work/intero/intero-script26587REU deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script26587REU +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script26587S-m b/.stack-work/intero/intero-script26587S-m deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script26587S-m +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script26587sZn b/.stack-work/intero/intero-script26587sZn deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script26587sZn +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script31583KtK b/.stack-work/intero/intero-script31583KtK deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script31583KtK +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script31583X3Q b/.stack-work/intero/intero-script31583X3Q deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script31583X3Q +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script38150SJ b/.stack-work/intero/intero-script38150SJ deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script38150SJ +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script3815OuJ b/.stack-work/intero/intero-script3815OuJ deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script3815OuJ +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script3815a3I b/.stack-work/intero/intero-script3815a3I deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script3815a3I +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script3815nBP b/.stack-work/intero/intero-script3815nBP deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script3815nBP +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script4078Wgy b/.stack-work/intero/intero-script4078Wgy deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script4078Wgy +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script75130iQ b/.stack-work/intero/intero-script75130iQ deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script75130iQ +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero-script7513nYK b/.stack-work/intero/intero-script7513nYK deleted file mode 100644 index 56fbd62..0000000 --- a/.stack-work/intero/intero-script7513nYK +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | :set prompt "" | ||
2 | :set -fbyte-code | ||
3 | :set -fdiagnostics-color=never | ||
4 | :set prompt "\4 " | ||
diff --git a/.stack-work/intero/intero15638-bM-STAGING.hs b/.stack-work/intero/intero15638-bM-STAGING.hs deleted file mode 100644 index ef7396b..0000000 --- a/.stack-work/intero/intero15638-bM-STAGING.hs +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | --import Numeric.LinearAlgebra | ||
8 | import System.Random | ||
9 | import Foreign.Storable | ||
10 | |||
11 | |||
12 | data Square = X -- Attacked | ||
13 | | Qu -- Queen | ||
14 | | O -- Open/available | ||
15 | deriving (Show, Eq) | ||
16 | |||
17 | |||
18 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
19 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
20 | |||
21 | lo8 = [0..8] -- list of 8 | ||
22 | initBoard = matrix 8 8 $ \_ -> O | ||
23 | |||
24 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
25 | where | ||
26 | placeQueen' b = setElem Qu (r,c) b | ||
27 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
28 | fX = (\_ x -> X) | ||
29 | rowAttacked b = mapRow fX r b | ||
30 | colAttacked b = mapCol fX c b | ||
31 | diagAttacked b = let d = diag r c | ||
32 | attack ap ab = setElem X ap ab | ||
33 | attackall [x] = attack x b | ||
34 | attackall (x:xs) = attack x (attackall xs) | ||
35 | in attackall d | ||
36 | -- in last $ map (\p -> setElem X p b) d | ||
37 | -- in last $ scanr (\p -> setElem X p) b | ||
38 | |||
39 | --solve b = placeQueen (nextAvail b) b | ||
40 | |||
41 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
42 | |||
43 | -- solve b = placeQueen n | ||
44 | -- where n = nextAvail b | ||
45 | -- next = placeQueen n | ||
46 | -- solve' = | ||
47 | |||
48 | solve b = | ||
49 | where solve' b = (\n = placeQueen $ nextAvail b) | ||
50 | |||
51 | |||
52 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
53 | diag r c = let rl = [1..r] | ||
54 | rr = [r..8] | ||
55 | cu = [1..c] | ||
56 | cd = [c..8] | ||
57 | in zip rl cu ++ zip rr cd ++ | ||
58 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
59 | |||
60 | |||
61 | |||
62 | |||
63 | -- diag (r,c) b = | ||
64 | -- where l = (r-1,c-1) | ||
65 | -- r = (r+1,c+1) | ||
66 | -- lowbound = 1 | ||
67 | -- highbound = 8 | ||
68 | |||
69 | |||
70 | --initBoard = (8><8) $ repeat O | ||
71 | |||
72 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
73 | |||
74 | -- firstOpen b = let | ||
75 | -- elem x y = b ! (x, y) | ||
76 | -- in map | ||
77 | |||
78 | -- nextOpen b = | ||
79 | |||
80 | -- solve = let board = initBoard | ||
81 | |||
82 | --avail r c b = | ||
83 | |||
84 | --rowOccupied r b = any (== Q) $ getRow r b | ||
85 | |||
86 | |||
87 | |||
88 | -- diags p = let r = r p | ||
89 | -- l = l p | ||
90 | -- in p : inRange r | ||
91 | -- where inRange x = x >= 1 && x <= 8 | ||
92 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
93 | -- r x = (fst x + 1, snd x + 1) | ||
94 | -- l x = (fst x - 1, snd x - 1) | ||
95 | -- nexts x = diags' x | ||
96 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
97 | -- -- down x = (fst x - 1, snd x - 1) | ||
98 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
99 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
100 | |||
101 | |||
102 | --mapDiag r c = undefined | ||
103 | |||
104 | --placeAll = repeat 8 placeQueen | ||
105 | |||
106 | winnable = undefined | ||
107 | |||
108 | nextOpen board = undefined | ||
109 | |||
110 | -- placeQueen r c = | ||
111 | |||
112 | --b = getE | ||
113 | |||
114 | --placeQueen r c b = b ^. | ||
115 | |||
116 | -- rand = do | ||
117 | -- g <- newStdGen | ||
118 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
119 | |||
120 | |||
121 | -- try r c = let next b = placeQueen r c b | ||
122 | -- in next initBoard | ||
123 | |||
124 | -- try' p = let next b = p b | ||
125 | -- in next initBoard | ||
126 | |||
127 | |||
128 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
129 | |||
130 | main :: IO () | ||
131 | main = do | ||
132 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero15638LmS-TEMP.hs b/.stack-work/intero/intero15638LmS-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero15638LmS-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero18425meY-STAGING.hs b/.stack-work/intero/intero18425meY-STAGING.hs deleted file mode 100644 index 820de4e..0000000 --- a/.stack-work/intero/intero18425meY-STAGING.hs +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X | Q deriving (Show) | ||
10 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
11 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
12 | |||
13 | lo8 = [0..8] -- list of 8 | ||
14 | initBoard = matrix 8 8 $ \_ -> X | ||
15 | --avail r c b = | ||
16 | |||
17 | --rowOccupied r b = any (== Q) $ getRow r b | ||
18 | placeQueen r c b = setElem Q (r,c) b | ||
19 | |||
20 | --placeAll = repeat 8 placeQueen | ||
21 | |||
22 | winnable = undefined | ||
23 | |||
24 | -- placeQueen r c = | ||
25 | |||
26 | --b = getE | ||
27 | |||
28 | --placeQueen r c b = b ^. | ||
29 | |||
30 | -- rand = do | ||
31 | -- g <- newStdGen | ||
32 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
33 | |||
34 | |||
35 | -- try r c = let next b = placeQueen r c b | ||
36 | -- in next initBoard | ||
37 | |||
38 | -- try' p = let next b = p b | ||
39 | -- in next initBoard | ||
40 | |||
41 | |||
42 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
43 | |||
44 | main :: IO () | ||
45 | main = do | ||
46 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero18425zoe-TEMP.hs b/.stack-work/intero/intero18425zoe-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero18425zoe-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero21871-0P-TEMP.hs b/.stack-work/intero/intero21871-0P-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero21871-0P-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero21871xqJ-STAGING.hs b/.stack-work/intero/intero21871xqJ-STAGING.hs deleted file mode 100644 index 820de4e..0000000 --- a/.stack-work/intero/intero21871xqJ-STAGING.hs +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X | Q deriving (Show) | ||
10 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
11 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
12 | |||
13 | lo8 = [0..8] -- list of 8 | ||
14 | initBoard = matrix 8 8 $ \_ -> X | ||
15 | --avail r c b = | ||
16 | |||
17 | --rowOccupied r b = any (== Q) $ getRow r b | ||
18 | placeQueen r c b = setElem Q (r,c) b | ||
19 | |||
20 | --placeAll = repeat 8 placeQueen | ||
21 | |||
22 | winnable = undefined | ||
23 | |||
24 | -- placeQueen r c = | ||
25 | |||
26 | --b = getE | ||
27 | |||
28 | --placeQueen r c b = b ^. | ||
29 | |||
30 | -- rand = do | ||
31 | -- g <- newStdGen | ||
32 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
33 | |||
34 | |||
35 | -- try r c = let next b = placeQueen r c b | ||
36 | -- in next initBoard | ||
37 | |||
38 | -- try' p = let next b = p b | ||
39 | -- in next initBoard | ||
40 | |||
41 | |||
42 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
43 | |||
44 | main :: IO () | ||
45 | main = do | ||
46 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero232079je-TEMP.hs b/.stack-work/intero/intero232079je-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero232079je-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero23207wZY-STAGING.hs b/.stack-work/intero/intero23207wZY-STAGING.hs deleted file mode 100644 index 820de4e..0000000 --- a/.stack-work/intero/intero23207wZY-STAGING.hs +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X | Q deriving (Show) | ||
10 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
11 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
12 | |||
13 | lo8 = [0..8] -- list of 8 | ||
14 | initBoard = matrix 8 8 $ \_ -> X | ||
15 | --avail r c b = | ||
16 | |||
17 | --rowOccupied r b = any (== Q) $ getRow r b | ||
18 | placeQueen r c b = setElem Q (r,c) b | ||
19 | |||
20 | --placeAll = repeat 8 placeQueen | ||
21 | |||
22 | winnable = undefined | ||
23 | |||
24 | -- placeQueen r c = | ||
25 | |||
26 | --b = getE | ||
27 | |||
28 | --placeQueen r c b = b ^. | ||
29 | |||
30 | -- rand = do | ||
31 | -- g <- newStdGen | ||
32 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
33 | |||
34 | |||
35 | -- try r c = let next b = placeQueen r c b | ||
36 | -- in next initBoard | ||
37 | |||
38 | -- try' p = let next b = p b | ||
39 | -- in next initBoard | ||
40 | |||
41 | |||
42 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
43 | |||
44 | main :: IO () | ||
45 | main = do | ||
46 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero25034GFG-TEMP.hs b/.stack-work/intero/intero25034GFG-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero25034GFG-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero25034U72-STAGING.hs b/.stack-work/intero/intero25034U72-STAGING.hs deleted file mode 100644 index 9cd992d..0000000 --- a/.stack-work/intero/intero25034U72-STAGING.hs +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | main :: IO () | ||
4 | main = do | ||
5 | putStrLn "hello world" | ||
diff --git a/.stack-work/intero/intero265874by-STAGING.hs b/.stack-work/intero/intero265874by-STAGING.hs deleted file mode 100644 index a82dbd0..0000000 --- a/.stack-work/intero/intero265874by-STAGING.hs +++ /dev/null | |||
@@ -1,201 +0,0 @@ | |||
1 | {-# LANGUAGE FlexibleContexts #-} | ||
2 | |||
3 | module Main where | ||
4 | |||
5 | import Control.Lens | ||
6 | import Linear.V2 | ||
7 | import Linear.V3 | ||
8 | import Data.Matrix | ||
9 | --import Numeric.LinearAlgebra | ||
10 | import System.Random | ||
11 | import Foreign.Storable | ||
12 | |||
13 | |||
14 | data Square = X -- Attacked | ||
15 | | Qu -- Queen | ||
16 | | O -- Open/available | ||
17 | deriving (Show, Eq) | ||
18 | |||
19 | |||
20 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
21 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
22 | |||
23 | lo8 = [0..8] -- list of 8 | ||
24 | initBoard = matrix 8 8 $ \_ -> O | ||
25 | |||
26 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
27 | where | ||
28 | placeQueen' b = setElem Qu (r,c) b | ||
29 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
30 | fX = (\_ x -> X) | ||
31 | rowAttacked b = mapRow fX r b | ||
32 | colAttacked b = mapCol fX c b | ||
33 | diagAttacked b = let d = diag r c | ||
34 | attack ap ab = setElem X ap ab | ||
35 | attackall [x] = attack x b | ||
36 | attackall (x:xs) = attack x (attackall xs) | ||
37 | in attackall d | ||
38 | -- in last $ map (\p -> setElem X p b) d | ||
39 | -- in last $ scanr (\p -> setElem X p) b | ||
40 | |||
41 | --solve b = placeQueen (nextAvail b) b | ||
42 | |||
43 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
44 | |||
45 | -- solve b = placeQueen n | ||
46 | -- where n = nextAvail b | ||
47 | -- next = placeQueen n | ||
48 | -- solve' = | ||
49 | |||
50 | -- solve b = | ||
51 | -- where solve' b = (\n = placeQueen $ nextAvail b) | ||
52 | |||
53 | solve b = second | ||
54 | where first = placeQueen (nextAvail b) b | ||
55 | second = placeQueen (nextAvail first) first | ||
56 | |||
57 | solve' b = s (nA b) b | ||
58 | where s n b = placeQueen n b | ||
59 | nA b = nextAvail b | ||
60 | |||
61 | |||
62 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
63 | diag r c = let rl = [1..r] | ||
64 | rr = [r..8] | ||
65 | cu = [1..c] | ||
66 | cd = [c..8] | ||
67 | in zip rl cu ++ zip rr cd ++ | ||
68 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
69 | |||
70 | allops a b = [(a, a), (a, b), (b, a), (b, b)] | ||
71 | ops = allops (+1) (subtract 1) | ||
72 | applyop (x,y) (a,b) = (a x,b y) | ||
73 | applyops p = map (applyop p) ops | ||
74 | |||
75 | mapDiag f c b = map (\(x,y) -> setElem f (x,y) b) ds | ||
76 | where ds = diag'' c | ||
77 | |||
78 | mapDiag' f c b = map (on b f) ds | ||
79 | where ds = diag'' c | ||
80 | on b x p = let next bo = set x p bo | ||
81 | in map (next) b | ||
82 | set x p b = setElem x p b | ||
83 | |||
84 | --mapDiag'' f c b = take 10 $ iterate (map (set f) ds) b | ||
85 | -- mapDiag'' f c b = take 10 $ iterate ( | ||
86 | -- where ds = diag'' c | ||
87 | -- eachD' p = setElem f p | ||
88 | -- eachD [p] = eachD' p | ||
89 | -- eachD (p:ps) = eachD' p : eachD ps | ||
90 | |||
91 | markX p b = setElem X p b | ||
92 | |||
93 | mapDiag''' f p b = applyfs fs b | ||
94 | where ds = diag'' p | ||
95 | fs = map (\x y -> markX x y) ds | ||
96 | applyfs [x] b = x b | ||
97 | applyfs (x:xs) b = applyfs x (applyfs xs) | ||
98 | |||
99 | |||
100 | onBoard b f = let next n = f n | ||
101 | in next b | ||
102 | |||
103 | --eB = mapDiag''' (\_ -> 1) (5,5) $ matrix 8 8 (\_ -> 0) | ||
104 | |||
105 | diag'' c = apply c | ||
106 | where | ||
107 | min = 1 | ||
108 | max = 8 | ||
109 | ops a b = [(a, a), (a, b), (b, a), (b, b)] | ||
110 | allops = ops (+1) (subtract 1) | ||
111 | applyop (x,y) (a,b) = (a x,b y) | ||
112 | applyopr (a,b) (x,y) = traverse' (\(d,f) -> (a d, b f)) (x,y) | ||
113 | traverse' f x = takeWhile (within) $ iterate f x | ||
114 | within (x,y) = let within' z = z >= min && z <= max | ||
115 | in within' x && within' y | ||
116 | applyops ops p = map (\x -> applyopr x p) ops | ||
117 | apply x = concat $ applyops allops x | ||
118 | |||
119 | -- opfs ops = map (\(o1,o2) -> (\(x,y) -> (o1 x, o2 y))) ops | ||
120 | -- applyops x = map x opfs | ||
121 | -- ops = map ( | ||
122 | --applyops (x,y) = map (($ x), ($ y)) $ allops (+1) (-1) | ||
123 | -- fx a b = map \((oa,ob) -> ((cx,cy) -> (oa cx, ob cy))) $ allops (+1) (-1) | ||
124 | --applyops x = [(((fst f) (fst x)), ((snd f) (snd x))) | f <- allops (+1) (-1)] | ||
125 | -- applyops x = (fst x, snd x) | ||
126 | -- applyops x = map \((p,m) -> (p (fst x), m (snd x))) $ allops (+1) (-1) | ||
127 | -- apply c = map (\(p,m) -> (p (fst c), m (snd c))) $ allops (+1) (-1) | ||
128 | -- apply ops c = [( (fst o) (fst c), (snd o) (snd c) | o <- ops | ||
129 | |||
130 | |||
131 | |||
132 | -- diag (r,c) b = | ||
133 | -- where l = (r-1,c-1) | ||
134 | -- r = (r+1,c+1) | ||
135 | -- lowbound = 1 | ||
136 | -- highbound = 8 | ||
137 | |||
138 | |||
139 | --initBoard = (8><8) $ repeat O | ||
140 | |||
141 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
142 | |||
143 | -- firstOpen b = let | ||
144 | -- elem x y = b ! (x, y) | ||
145 | -- in map | ||
146 | |||
147 | -- nextOpen b = | ||
148 | |||
149 | -- solve = let board = initBoard | ||
150 | |||
151 | --avail r c b = | ||
152 | |||
153 | --rowOccupied r b = any (== Q) $ getRow r b | ||
154 | |||
155 | |||
156 | |||
157 | -- diags p = let r = r p | ||
158 | -- l = l p | ||
159 | -- in p : inRange r | ||
160 | -- where inRange x = x >= 1 && x <= 8 | ||
161 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
162 | -- r x = (fst x + 1, snd x + 1) | ||
163 | -- l x = (fst x - 1, snd x - 1) | ||
164 | -- nexts x = diags' x | ||
165 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
166 | -- -- down x = (fst x - 1, snd x - 1) | ||
167 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
168 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
169 | |||
170 | |||
171 | --mapDiag r c = undefined | ||
172 | |||
173 | --placeAll = repeat 8 placeQueen | ||
174 | |||
175 | winnable = undefined | ||
176 | |||
177 | nextOpen board = undefined | ||
178 | |||
179 | -- placeQueen r c = | ||
180 | |||
181 | --b = getE | ||
182 | |||
183 | --placeQueen r c b = b ^. | ||
184 | |||
185 | -- rand = do | ||
186 | -- g <- newStdGen | ||
187 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
188 | |||
189 | |||
190 | -- try r c = let next b = placeQueen r c b | ||
191 | -- in next initBoard | ||
192 | |||
193 | -- try' p = let next b = p b | ||
194 | -- in next initBoard | ||
195 | |||
196 | |||
197 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
198 | |||
199 | main :: IO () | ||
200 | main = do | ||
201 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero26587qlB-TEMP.hs b/.stack-work/intero/intero26587qlB-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero26587qlB-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero30739dbu-STAGING.hs b/.stack-work/intero/intero30739dbu-STAGING.hs deleted file mode 100644 index c0b9790..0000000 --- a/.stack-work/intero/intero30739dbu-STAGING.hs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | --import Numeric.LinearAlgebra | ||
8 | import System.Random | ||
9 | import Foreign.Storable | ||
10 | |||
11 | |||
12 | data Square = X -- Attacked | ||
13 | | Qu -- Queen | ||
14 | | O -- Open/available | ||
15 | deriving (Show, Eq) | ||
16 | |||
17 | |||
18 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
19 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
20 | |||
21 | lo8 = [0..8] -- list of 8 | ||
22 | initBoard = matrix 8 8 $ \_ -> O | ||
23 | |||
24 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
25 | where | ||
26 | placeQueen' b = setElem Qu (r,c) b | ||
27 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
28 | fX = (\_ x -> X) | ||
29 | rowAttacked b = mapRow fX r b | ||
30 | colAttacked b = mapCol fX c b | ||
31 | diagAttacked b = let d = diag r c | ||
32 | attack ap ab = setElem X ap ab | ||
33 | attackall [x] = attack x b | ||
34 | attackall (x:xs) = attack x (attackall xs) | ||
35 | in attackall d | ||
36 | -- in last $ map (\p -> setElem X p b) d | ||
37 | -- in last $ scanr (\p -> setElem X p) b | ||
38 | |||
39 | --solve b = placeQueen (nextAvail b) b | ||
40 | |||
41 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
42 | |||
43 | solve b = solve $ placeQueen n b | ||
44 | where n = nextAvail b | ||
45 | |||
46 | |||
47 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
48 | diag r c = let rl = [1..r] | ||
49 | rr = [r..8] | ||
50 | cu = [1..c] | ||
51 | cd = [c..8] | ||
52 | in zip rl cu ++ zip rr cd ++ | ||
53 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | -- diag (r,c) b = | ||
59 | -- where l = (r-1,c-1) | ||
60 | -- r = (r+1,c+1) | ||
61 | -- lowbound = 1 | ||
62 | -- highbound = 8 | ||
63 | |||
64 | |||
65 | --initBoard = (8><8) $ repeat O | ||
66 | |||
67 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
68 | |||
69 | -- firstOpen b = let | ||
70 | -- elem x y = b ! (x, y) | ||
71 | -- in map | ||
72 | |||
73 | -- nextOpen b = | ||
74 | |||
75 | -- solve = let board = initBoard | ||
76 | |||
77 | --avail r c b = | ||
78 | |||
79 | --rowOccupied r b = any (== Q) $ getRow r b | ||
80 | |||
81 | |||
82 | |||
83 | -- diags p = let r = r p | ||
84 | -- l = l p | ||
85 | -- in p : inRange r | ||
86 | -- where inRange x = x >= 1 && x <= 8 | ||
87 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
88 | -- r x = (fst x + 1, snd x + 1) | ||
89 | -- l x = (fst x - 1, snd x - 1) | ||
90 | -- nexts x = diags' x | ||
91 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
92 | -- -- down x = (fst x - 1, snd x - 1) | ||
93 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
94 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
95 | |||
96 | |||
97 | --mapDiag r c = undefined | ||
98 | |||
99 | --placeAll = repeat 8 placeQueen | ||
100 | |||
101 | winnable = undefined | ||
102 | |||
103 | nextOpen board = undefined | ||
104 | |||
105 | -- placeQueen r c = | ||
106 | |||
107 | --b = getE | ||
108 | |||
109 | --placeQueen r c b = b ^. | ||
110 | |||
111 | -- rand = do | ||
112 | -- g <- newStdGen | ||
113 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
114 | |||
115 | |||
116 | -- try r c = let next b = placeQueen r c b | ||
117 | -- in next initBoard | ||
118 | |||
119 | -- try' p = let next b = p b | ||
120 | -- in next initBoard | ||
121 | |||
122 | |||
123 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
124 | |||
125 | main :: IO () | ||
126 | main = do | ||
127 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero30739ql0-TEMP.hs b/.stack-work/intero/intero30739ql0-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero30739ql0-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero31583k6i-STAGING.hs b/.stack-work/intero/intero31583k6i-STAGING.hs deleted file mode 100644 index c020aed..0000000 --- a/.stack-work/intero/intero31583k6i-STAGING.hs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | --import Numeric.LinearAlgebra | ||
8 | import System.Random | ||
9 | import Foreign.Storable | ||
10 | |||
11 | |||
12 | data Square = X -- Attacked | ||
13 | | Qu -- Queen | ||
14 | | O -- Open/available | ||
15 | deriving (Show, Eq) | ||
16 | |||
17 | |||
18 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
19 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
20 | |||
21 | lo8 = [0..8] -- list of 8 | ||
22 | initBoard = matrix 8 8 $ \_ -> O | ||
23 | |||
24 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
25 | where | ||
26 | placeQueen' b = setElem Qu (r,c) b | ||
27 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
28 | fX = (\_ x -> X) | ||
29 | rowAttacked b = mapRow fX r b | ||
30 | colAttacked b = mapCol fX c b | ||
31 | diagAttacked b = let d = diag r c | ||
32 | attack ap ab = setElem X ap ab | ||
33 | attackall [x] = attack x b | ||
34 | attackall (x:xs) = attack x (attackall xs) | ||
35 | in attackall d | ||
36 | -- in last $ map (\p -> setElem X p b) d | ||
37 | -- in last $ scanr (\p -> setElem X p) b | ||
38 | |||
39 | --solve b = placeQueen (nextAvail b) b | ||
40 | |||
41 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
42 | |||
43 | solve b = solve $ solve $ solve $ placeQueen n b | ||
44 | where n = nextAvail b | ||
45 | |||
46 | |||
47 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
48 | diag r c = let rl = [1..r] | ||
49 | rr = [r..8] | ||
50 | cu = [1..c] | ||
51 | cd = [c..8] | ||
52 | in zip rl cu ++ zip rr cd ++ | ||
53 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | -- diag (r,c) b = | ||
59 | -- where l = (r-1,c-1) | ||
60 | -- r = (r+1,c+1) | ||
61 | -- lowbound = 1 | ||
62 | -- highbound = 8 | ||
63 | |||
64 | |||
65 | --initBoard = (8><8) $ repeat O | ||
66 | |||
67 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
68 | |||
69 | -- firstOpen b = let | ||
70 | -- elem x y = b ! (x, y) | ||
71 | -- in map | ||
72 | |||
73 | -- nextOpen b = | ||
74 | |||
75 | -- solve = let board = initBoard | ||
76 | |||
77 | --avail r c b = | ||
78 | |||
79 | --rowOccupied r b = any (== Q) $ getRow r b | ||
80 | |||
81 | |||
82 | |||
83 | -- diags p = let r = r p | ||
84 | -- l = l p | ||
85 | -- in p : inRange r | ||
86 | -- where inRange x = x >= 1 && x <= 8 | ||
87 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
88 | -- r x = (fst x + 1, snd x + 1) | ||
89 | -- l x = (fst x - 1, snd x - 1) | ||
90 | -- nexts x = diags' x | ||
91 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
92 | -- -- down x = (fst x - 1, snd x - 1) | ||
93 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
94 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
95 | |||
96 | |||
97 | --mapDiag r c = undefined | ||
98 | |||
99 | --placeAll = repeat 8 placeQueen | ||
100 | |||
101 | winnable = undefined | ||
102 | |||
103 | nextOpen board = undefined | ||
104 | |||
105 | -- placeQueen r c = | ||
106 | |||
107 | --b = getE | ||
108 | |||
109 | --placeQueen r c b = b ^. | ||
110 | |||
111 | -- rand = do | ||
112 | -- g <- newStdGen | ||
113 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
114 | |||
115 | |||
116 | -- try r c = let next b = placeQueen r c b | ||
117 | -- in next initBoard | ||
118 | |||
119 | -- try' p = let next b = p b | ||
120 | -- in next initBoard | ||
121 | |||
122 | |||
123 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
124 | |||
125 | main :: IO () | ||
126 | main = do | ||
127 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero31583xEp-TEMP.hs b/.stack-work/intero/intero31583xEp-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero31583xEp-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero38150Eh-TEMP.hs b/.stack-work/intero/intero38150Eh-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero38150Eh-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero3815n6a-STAGING.hs b/.stack-work/intero/intero3815n6a-STAGING.hs deleted file mode 100644 index 5f6fce5..0000000 --- a/.stack-work/intero/intero3815n6a-STAGING.hs +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X -- Attacked | ||
10 | | Qu -- Queen | ||
11 | | O -- Open/available | ||
12 | deriving (Show) | ||
13 | |||
14 | |||
15 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
16 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
17 | |||
18 | lo8 = [0..8] -- list of 8 | ||
19 | initBoard = matrix 8 8 $ \_ -> O | ||
20 | |||
21 | firstOpen b = let | ||
22 | elem x y = b ! (x, y) | ||
23 | in map | ||
24 | |||
25 | nextOpen b = | ||
26 | |||
27 | solve = let board = initBoard | ||
28 | |||
29 | --avail r c b = | ||
30 | |||
31 | --rowOccupied r b = any (== Q) $ getRow r b | ||
32 | -- placeQueen r c b = board | ||
33 | -- where | ||
34 | -- fX = (\ _ -> X) | ||
35 | -- rowAttacked = mapRow fX r | ||
36 | -- colAttacked = mapCol fx c | ||
37 | -- queen = setElem Qu (r,c) b | ||
38 | |||
39 | --placeAll = repeat 8 placeQueen | ||
40 | |||
41 | winnable = undefined | ||
42 | |||
43 | nextOpen board = undefined | ||
44 | |||
45 | solve = undefined | ||
46 | |||
47 | -- placeQueen r c = | ||
48 | |||
49 | --b = getE | ||
50 | |||
51 | --placeQueen r c b = b ^. | ||
52 | |||
53 | -- rand = do | ||
54 | -- g <- newStdGen | ||
55 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
56 | |||
57 | |||
58 | -- try r c = let next b = placeQueen r c b | ||
59 | -- in next initBoard | ||
60 | |||
61 | -- try' p = let next b = p b | ||
62 | -- in next initBoard | ||
63 | |||
64 | |||
65 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
66 | |||
67 | main :: IO () | ||
68 | main = do | ||
69 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero4078i3Z-STAGING.hs b/.stack-work/intero/intero4078i3Z-STAGING.hs deleted file mode 100644 index 15be3ec..0000000 --- a/.stack-work/intero/intero4078i3Z-STAGING.hs +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X | Qu | O deriving (Show) | ||
10 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
11 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
12 | |||
13 | lo8 = [0..8] -- list of 8 | ||
14 | initBoard = matrix 8 8 $ \_ -> O | ||
15 | --avail r c b = | ||
16 | |||
17 | --rowOccupied r b = any (== Q) $ getRow r b | ||
18 | placeQueen r c b = board | ||
19 | where | ||
20 | fX = (\ _ -> X) | ||
21 | rowAttacked = mapRow fX r | ||
22 | colAttacked = mapCol fx c | ||
23 | queen = setElem Qu (r,c) b | ||
24 | |||
25 | --placeAll = repeat 8 placeQueen | ||
26 | |||
27 | winnable = undefined | ||
28 | |||
29 | nextOpen board = | ||
30 | |||
31 | solve = | ||
32 | |||
33 | -- placeQueen r c = | ||
34 | |||
35 | --b = getE | ||
36 | |||
37 | --placeQueen r c b = b ^. | ||
38 | |||
39 | -- rand = do | ||
40 | -- g <- newStdGen | ||
41 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
42 | |||
43 | |||
44 | -- try r c = let next b = placeQueen r c b | ||
45 | -- in next initBoard | ||
46 | |||
47 | -- try' p = let next b = p b | ||
48 | -- in next initBoard | ||
49 | |||
50 | |||
51 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
52 | |||
53 | main :: IO () | ||
54 | main = do | ||
55 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero4078vBg-TEMP.hs b/.stack-work/intero/intero4078vBg-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero4078vBg-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero5164dbY-STAGING.hs b/.stack-work/intero/intero5164dbY-STAGING.hs deleted file mode 100644 index 820de4e..0000000 --- a/.stack-work/intero/intero5164dbY-STAGING.hs +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | import System.Random | ||
8 | |||
9 | data Square = X | Q deriving (Show) | ||
10 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
11 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
12 | |||
13 | lo8 = [0..8] -- list of 8 | ||
14 | initBoard = matrix 8 8 $ \_ -> X | ||
15 | --avail r c b = | ||
16 | |||
17 | --rowOccupied r b = any (== Q) $ getRow r b | ||
18 | placeQueen r c b = setElem Q (r,c) b | ||
19 | |||
20 | --placeAll = repeat 8 placeQueen | ||
21 | |||
22 | winnable = undefined | ||
23 | |||
24 | -- placeQueen r c = | ||
25 | |||
26 | --b = getE | ||
27 | |||
28 | --placeQueen r c b = b ^. | ||
29 | |||
30 | -- rand = do | ||
31 | -- g <- newStdGen | ||
32 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
33 | |||
34 | |||
35 | -- try r c = let next b = placeQueen r c b | ||
36 | -- in next initBoard | ||
37 | |||
38 | -- try' p = let next b = p b | ||
39 | -- in next initBoard | ||
40 | |||
41 | |||
42 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
43 | |||
44 | main :: IO () | ||
45 | main = do | ||
46 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero5164qle-TEMP.hs b/.stack-work/intero/intero5164qle-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero5164qle-TEMP.hs +++ /dev/null | |||
diff --git a/.stack-work/intero/intero7513Owo-STAGING.hs b/.stack-work/intero/intero7513Owo-STAGING.hs deleted file mode 100644 index f3b0098..0000000 --- a/.stack-work/intero/intero7513Owo-STAGING.hs +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | --import Numeric.LinearAlgebra | ||
8 | import System.Random | ||
9 | import Foreign.Storable | ||
10 | |||
11 | |||
12 | data Square = X -- Attacked | ||
13 | | Qu -- Queen | ||
14 | | O -- Open/available | ||
15 | deriving (Show, Eq) | ||
16 | |||
17 | |||
18 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
19 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
20 | |||
21 | lo8 = [0..8] -- list of 8 | ||
22 | initBoard = matrix 8 8 $ \_ -> O | ||
23 | |||
24 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
25 | where | ||
26 | placeQueen' b = setElem Qu (r,c) b | ||
27 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
28 | fX = (\_ x -> X) | ||
29 | rowAttacked b = mapRow fX r b | ||
30 | colAttacked b = mapCol fX c b | ||
31 | diagAttacked b = let d = diag r c | ||
32 | attack ap ab = setElem X ap ab | ||
33 | attackall [x] = attack x b | ||
34 | attackall (x:xs) = attack x (attackall xs) | ||
35 | in attackall d | ||
36 | -- in last $ map (\p -> setElem X p b) d | ||
37 | -- in last $ scanr (\p -> setElem X p) b | ||
38 | |||
39 | --solve b = placeQueen (nextAvail b) b | ||
40 | |||
41 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
42 | |||
43 | -- solve b = placeQueen n | ||
44 | -- where n = nextAvail b | ||
45 | -- next = placeQueen n | ||
46 | -- solve' = | ||
47 | |||
48 | -- solve b = | ||
49 | -- where solve' b = (\n = placeQueen $ nextAvail b) | ||
50 | |||
51 | solve b = second | ||
52 | where first = placeQueen (nextAvail b) b | ||
53 | second = placeQueen (nextAvail first) first | ||
54 | |||
55 | solve' b = s (nA b) b | ||
56 | where s n b = placeQueen n b | ||
57 | nA b = nextAvail b | ||
58 | |||
59 | |||
60 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
61 | diag r c = let rl = [1..r] | ||
62 | rr = [r..8] | ||
63 | cu = [1..c] | ||
64 | cd = [c..8] | ||
65 | in zip rl cu ++ zip rr cd ++ | ||
66 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
67 | |||
68 | diag' p = where | ||
69 | maxB = 8 | ||
70 | minB = 1 | ||
71 | u = (+1) | ||
72 | d = (-1) | ||
73 | r = u | ||
74 | l = d | ||
75 | ur = (u fst, r snd) | ||
76 | ul = (u fst, l snd) | ||
77 | dr = (d fst, r snd) | ||
78 | dl = (d fst, l snd) | ||
79 | |||
80 | |||
81 | |||
82 | |||
83 | -- diag (r,c) b = | ||
84 | -- where l = (r-1,c-1) | ||
85 | -- r = (r+1,c+1) | ||
86 | -- lowbound = 1 | ||
87 | -- highbound = 8 | ||
88 | |||
89 | |||
90 | --initBoard = (8><8) $ repeat O | ||
91 | |||
92 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
93 | |||
94 | -- firstOpen b = let | ||
95 | -- elem x y = b ! (x, y) | ||
96 | -- in map | ||
97 | |||
98 | -- nextOpen b = | ||
99 | |||
100 | -- solve = let board = initBoard | ||
101 | |||
102 | --avail r c b = | ||
103 | |||
104 | --rowOccupied r b = any (== Q) $ getRow r b | ||
105 | |||
106 | |||
107 | |||
108 | -- diags p = let r = r p | ||
109 | -- l = l p | ||
110 | -- in p : inRange r | ||
111 | -- where inRange x = x >= 1 && x <= 8 | ||
112 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
113 | -- r x = (fst x + 1, snd x + 1) | ||
114 | -- l x = (fst x - 1, snd x - 1) | ||
115 | -- nexts x = diags' x | ||
116 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
117 | -- -- down x = (fst x - 1, snd x - 1) | ||
118 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
119 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
120 | |||
121 | |||
122 | --mapDiag r c = undefined | ||
123 | |||
124 | --placeAll = repeat 8 placeQueen | ||
125 | |||
126 | winnable = undefined | ||
127 | |||
128 | nextOpen board = undefined | ||
129 | |||
130 | -- placeQueen r c = | ||
131 | |||
132 | --b = getE | ||
133 | |||
134 | --placeQueen r c b = b ^. | ||
135 | |||
136 | -- rand = do | ||
137 | -- g <- newStdGen | ||
138 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
139 | |||
140 | |||
141 | -- try r c = let next b = placeQueen r c b | ||
142 | -- in next initBoard | ||
143 | |||
144 | -- try' p = let next b = p b | ||
145 | -- in next initBoard | ||
146 | |||
147 | |||
148 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
149 | |||
150 | main :: IO () | ||
151 | main = do | ||
152 | putStrLn "Hi" | ||
diff --git a/.stack-work/intero/intero7513b6u-TEMP.hs b/.stack-work/intero/intero7513b6u-TEMP.hs deleted file mode 100644 index e69de29..0000000 --- a/.stack-work/intero/intero7513b6u-TEMP.hs +++ /dev/null | |||