From ba07f3549313ad470fe2de9e0cac72556afb8046 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 30 May 2019 13:06:39 -0400 Subject: ignore .stack-work --- .stack-work/intero/intero-script15638LtG | 4 - .stack-work/intero/intero-script18425zvS | 4 - .stack-work/intero/intero-script21871YJc | 4 - .stack-work/intero/intero-script250346te | 4 - .stack-work/intero/intero-script25034H4k | 4 - .stack-work/intero/intero-script25034UCr | 4 - .stack-work/intero/intero-script25034UQT | 4 - .stack-work/intero/intero-script25034gZS | 4 - .stack-work/intero/intero-script25034haZ | 4 - .stack-work/intero/intero-script25034tjY | 4 - .stack-work/intero/intero-script265874pa | 4 - .stack-work/intero/intero-script26587REU | 4 - .stack-work/intero/intero-script26587S-m | 4 - .stack-work/intero/intero-script26587sZn | 4 - .stack-work/intero/intero-script31583KtK | 4 - .stack-work/intero/intero-script31583X3Q | 4 - .stack-work/intero/intero-script38150SJ | 4 - .stack-work/intero/intero-script3815OuJ | 4 - .stack-work/intero/intero-script3815a3I | 4 - .stack-work/intero/intero-script3815nBP | 4 - .stack-work/intero/intero-script4078Wgy | 4 - .stack-work/intero/intero-script75130iQ | 4 - .stack-work/intero/intero-script7513nYK | 4 - .stack-work/intero/intero15638-bM-STAGING.hs | 132 ------------------ .stack-work/intero/intero15638LmS-TEMP.hs | 0 .stack-work/intero/intero18425meY-STAGING.hs | 46 ------ .stack-work/intero/intero18425zoe-TEMP.hs | 0 .stack-work/intero/intero21871-0P-TEMP.hs | 0 .stack-work/intero/intero21871xqJ-STAGING.hs | 46 ------ .stack-work/intero/intero232079je-TEMP.hs | 0 .stack-work/intero/intero23207wZY-STAGING.hs | 46 ------ .stack-work/intero/intero25034GFG-TEMP.hs | 0 .stack-work/intero/intero25034U72-STAGING.hs | 5 - .stack-work/intero/intero265874by-STAGING.hs | 201 --------------------------- .stack-work/intero/intero26587qlB-TEMP.hs | 0 .stack-work/intero/intero30739dbu-STAGING.hs | 127 ----------------- .stack-work/intero/intero30739ql0-TEMP.hs | 0 .stack-work/intero/intero31583k6i-STAGING.hs | 127 ----------------- .stack-work/intero/intero31583xEp-TEMP.hs | 0 .stack-work/intero/intero38150Eh-TEMP.hs | 0 .stack-work/intero/intero3815n6a-STAGING.hs | 69 --------- .stack-work/intero/intero4078i3Z-STAGING.hs | 55 -------- .stack-work/intero/intero4078vBg-TEMP.hs | 0 .stack-work/intero/intero5164dbY-STAGING.hs | 46 ------ .stack-work/intero/intero5164qle-TEMP.hs | 0 .stack-work/intero/intero7513Owo-STAGING.hs | 152 -------------------- .stack-work/intero/intero7513b6u-TEMP.hs | 0 47 files changed, 1144 deletions(-) delete mode 100644 .stack-work/intero/intero-script15638LtG delete mode 100644 .stack-work/intero/intero-script18425zvS delete mode 100644 .stack-work/intero/intero-script21871YJc delete mode 100644 .stack-work/intero/intero-script250346te delete mode 100644 .stack-work/intero/intero-script25034H4k delete mode 100644 .stack-work/intero/intero-script25034UCr delete mode 100644 .stack-work/intero/intero-script25034UQT delete mode 100644 .stack-work/intero/intero-script25034gZS delete mode 100644 .stack-work/intero/intero-script25034haZ delete mode 100644 .stack-work/intero/intero-script25034tjY delete mode 100644 .stack-work/intero/intero-script265874pa delete mode 100644 .stack-work/intero/intero-script26587REU delete mode 100644 .stack-work/intero/intero-script26587S-m delete mode 100644 .stack-work/intero/intero-script26587sZn delete mode 100644 .stack-work/intero/intero-script31583KtK delete mode 100644 .stack-work/intero/intero-script31583X3Q delete mode 100644 .stack-work/intero/intero-script38150SJ delete mode 100644 .stack-work/intero/intero-script3815OuJ delete mode 100644 .stack-work/intero/intero-script3815a3I delete mode 100644 .stack-work/intero/intero-script3815nBP delete mode 100644 .stack-work/intero/intero-script4078Wgy delete mode 100644 .stack-work/intero/intero-script75130iQ delete mode 100644 .stack-work/intero/intero-script7513nYK delete mode 100644 .stack-work/intero/intero15638-bM-STAGING.hs delete mode 100644 .stack-work/intero/intero15638LmS-TEMP.hs delete mode 100644 .stack-work/intero/intero18425meY-STAGING.hs delete mode 100644 .stack-work/intero/intero18425zoe-TEMP.hs delete mode 100644 .stack-work/intero/intero21871-0P-TEMP.hs delete mode 100644 .stack-work/intero/intero21871xqJ-STAGING.hs delete mode 100644 .stack-work/intero/intero232079je-TEMP.hs delete mode 100644 .stack-work/intero/intero23207wZY-STAGING.hs delete mode 100644 .stack-work/intero/intero25034GFG-TEMP.hs delete mode 100644 .stack-work/intero/intero25034U72-STAGING.hs delete mode 100644 .stack-work/intero/intero265874by-STAGING.hs delete mode 100644 .stack-work/intero/intero26587qlB-TEMP.hs delete mode 100644 .stack-work/intero/intero30739dbu-STAGING.hs delete mode 100644 .stack-work/intero/intero30739ql0-TEMP.hs delete mode 100644 .stack-work/intero/intero31583k6i-STAGING.hs delete mode 100644 .stack-work/intero/intero31583xEp-TEMP.hs delete mode 100644 .stack-work/intero/intero38150Eh-TEMP.hs delete mode 100644 .stack-work/intero/intero3815n6a-STAGING.hs delete mode 100644 .stack-work/intero/intero4078i3Z-STAGING.hs delete mode 100644 .stack-work/intero/intero4078vBg-TEMP.hs delete mode 100644 .stack-work/intero/intero5164dbY-STAGING.hs delete mode 100644 .stack-work/intero/intero5164qle-TEMP.hs delete mode 100644 .stack-work/intero/intero7513Owo-STAGING.hs delete mode 100644 .stack-work/intero/intero7513b6u-TEMP.hs (limited to '.stack-work/intero') 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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -:set prompt "" -:set -fbyte-code -:set -fdiagnostics-color=never -: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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix ---import Numeric.LinearAlgebra -import System.Random -import Foreign.Storable - - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show, Eq) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -placeQueen (r,c) b = placeQueen' $ markAttacked b - where - placeQueen' b = setElem Qu (r,c) b - markAttacked b = rowAttacked $ colAttacked $ diagAttacked b - fX = (\_ x -> X) - rowAttacked b = mapRow fX r b - colAttacked b = mapCol fX c b - diagAttacked b = let d = diag r c - attack ap ab = setElem X ap ab - attackall [x] = attack x b - attackall (x:xs) = attack x (attackall xs) - in attackall d --- in last $ map (\p -> setElem X p b) d --- in last $ scanr (\p -> setElem X p) b - ---solve b = placeQueen (nextAvail b) b - -nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] - --- solve b = placeQueen n --- where n = nextAvail b --- next = placeQueen n --- solve' = - -solve b = - where solve' b = (\n = placeQueen $ nextAvail b) - - ---diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] -diag r c = let rl = [1..r] - rr = [r..8] - cu = [1..c] - cd = [c..8] - in zip rl cu ++ zip rr cd ++ - zip (reverse rl) cd ++ zip (reverse rr) cu - - - - --- diag (r,c) b = --- where l = (r-1,c-1) --- r = (r+1,c+1) --- lowbound = 1 --- highbound = 8 - - ---initBoard = (8><8) $ repeat O - ---firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] - --- firstOpen b = let --- elem x y = b ! (x, y) --- in map - --- nextOpen b = - --- solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b - - - --- diags p = let r = r p --- l = l p --- in p : inRange r --- where inRange x = x >= 1 && x <= 8 --- inRange' (x,y) = inRange (x) && inRange (y) --- r x = (fst x + 1, snd x + 1) --- l x = (fst x - 1, snd x - 1) --- nexts x = diags' x --- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] --- -- down x = (fst x - 1, snd x - 1) --- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else --- -- up (r,c) = let u = (r+1,c+1) in u : up u - - ---mapDiag r c = undefined - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X | Q deriving (Show) ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> X ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b -placeQueen r c b = setElem Q (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X | Q deriving (Show) ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> X ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b -placeQueen r c b = setElem Q (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X | Q deriving (Show) ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> X ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b -placeQueen r c b = setElem Q (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -main :: IO () -main = do - 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 @@ -{-# LANGUAGE FlexibleContexts #-} - -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix ---import Numeric.LinearAlgebra -import System.Random -import Foreign.Storable - - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show, Eq) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -placeQueen (r,c) b = placeQueen' $ markAttacked b - where - placeQueen' b = setElem Qu (r,c) b - markAttacked b = rowAttacked $ colAttacked $ diagAttacked b - fX = (\_ x -> X) - rowAttacked b = mapRow fX r b - colAttacked b = mapCol fX c b - diagAttacked b = let d = diag r c - attack ap ab = setElem X ap ab - attackall [x] = attack x b - attackall (x:xs) = attack x (attackall xs) - in attackall d --- in last $ map (\p -> setElem X p b) d --- in last $ scanr (\p -> setElem X p) b - ---solve b = placeQueen (nextAvail b) b - -nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] - --- solve b = placeQueen n --- where n = nextAvail b --- next = placeQueen n --- solve' = - --- solve b = --- where solve' b = (\n = placeQueen $ nextAvail b) - -solve b = second - where first = placeQueen (nextAvail b) b - second = placeQueen (nextAvail first) first - -solve' b = s (nA b) b - where s n b = placeQueen n b - nA b = nextAvail b - - ---diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] -diag r c = let rl = [1..r] - rr = [r..8] - cu = [1..c] - cd = [c..8] - in zip rl cu ++ zip rr cd ++ - zip (reverse rl) cd ++ zip (reverse rr) cu - -allops a b = [(a, a), (a, b), (b, a), (b, b)] -ops = allops (+1) (subtract 1) -applyop (x,y) (a,b) = (a x,b y) -applyops p = map (applyop p) ops - -mapDiag f c b = map (\(x,y) -> setElem f (x,y) b) ds - where ds = diag'' c - -mapDiag' f c b = map (on b f) ds - where ds = diag'' c - on b x p = let next bo = set x p bo - in map (next) b - set x p b = setElem x p b - ---mapDiag'' f c b = take 10 $ iterate (map (set f) ds) b --- mapDiag'' f c b = take 10 $ iterate ( --- where ds = diag'' c --- eachD' p = setElem f p --- eachD [p] = eachD' p --- eachD (p:ps) = eachD' p : eachD ps - -markX p b = setElem X p b - -mapDiag''' f p b = applyfs fs b - where ds = diag'' p - fs = map (\x y -> markX x y) ds - applyfs [x] b = x b - applyfs (x:xs) b = applyfs x (applyfs xs) - - -onBoard b f = let next n = f n - in next b - ---eB = mapDiag''' (\_ -> 1) (5,5) $ matrix 8 8 (\_ -> 0) - -diag'' c = apply c - where - min = 1 - max = 8 - ops a b = [(a, a), (a, b), (b, a), (b, b)] - allops = ops (+1) (subtract 1) - applyop (x,y) (a,b) = (a x,b y) - applyopr (a,b) (x,y) = traverse' (\(d,f) -> (a d, b f)) (x,y) - traverse' f x = takeWhile (within) $ iterate f x - within (x,y) = let within' z = z >= min && z <= max - in within' x && within' y - applyops ops p = map (\x -> applyopr x p) ops - apply x = concat $ applyops allops x - --- opfs ops = map (\(o1,o2) -> (\(x,y) -> (o1 x, o2 y))) ops --- applyops x = map x opfs --- ops = map ( - --applyops (x,y) = map (($ x), ($ y)) $ allops (+1) (-1) --- fx a b = map \((oa,ob) -> ((cx,cy) -> (oa cx, ob cy))) $ allops (+1) (-1) - --applyops x = [(((fst f) (fst x)), ((snd f) (snd x))) | f <- allops (+1) (-1)] --- applyops x = (fst x, snd x) --- applyops x = map \((p,m) -> (p (fst x), m (snd x))) $ allops (+1) (-1) --- apply c = map (\(p,m) -> (p (fst c), m (snd c))) $ allops (+1) (-1) --- apply ops c = [( (fst o) (fst c), (snd o) (snd c) | o <- ops - - - --- diag (r,c) b = --- where l = (r-1,c-1) --- r = (r+1,c+1) --- lowbound = 1 --- highbound = 8 - - ---initBoard = (8><8) $ repeat O - ---firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] - --- firstOpen b = let --- elem x y = b ! (x, y) --- in map - --- nextOpen b = - --- solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b - - - --- diags p = let r = r p --- l = l p --- in p : inRange r --- where inRange x = x >= 1 && x <= 8 --- inRange' (x,y) = inRange (x) && inRange (y) --- r x = (fst x + 1, snd x + 1) --- l x = (fst x - 1, snd x - 1) --- nexts x = diags' x --- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] --- -- down x = (fst x - 1, snd x - 1) --- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else --- -- up (r,c) = let u = (r+1,c+1) in u : up u - - ---mapDiag r c = undefined - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix ---import Numeric.LinearAlgebra -import System.Random -import Foreign.Storable - - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show, Eq) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -placeQueen (r,c) b = placeQueen' $ markAttacked b - where - placeQueen' b = setElem Qu (r,c) b - markAttacked b = rowAttacked $ colAttacked $ diagAttacked b - fX = (\_ x -> X) - rowAttacked b = mapRow fX r b - colAttacked b = mapCol fX c b - diagAttacked b = let d = diag r c - attack ap ab = setElem X ap ab - attackall [x] = attack x b - attackall (x:xs) = attack x (attackall xs) - in attackall d --- in last $ map (\p -> setElem X p b) d --- in last $ scanr (\p -> setElem X p) b - ---solve b = placeQueen (nextAvail b) b - -nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] - -solve b = solve $ placeQueen n b - where n = nextAvail b - - ---diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] -diag r c = let rl = [1..r] - rr = [r..8] - cu = [1..c] - cd = [c..8] - in zip rl cu ++ zip rr cd ++ - zip (reverse rl) cd ++ zip (reverse rr) cu - - - - --- diag (r,c) b = --- where l = (r-1,c-1) --- r = (r+1,c+1) --- lowbound = 1 --- highbound = 8 - - ---initBoard = (8><8) $ repeat O - ---firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] - --- firstOpen b = let --- elem x y = b ! (x, y) --- in map - --- nextOpen b = - --- solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b - - - --- diags p = let r = r p --- l = l p --- in p : inRange r --- where inRange x = x >= 1 && x <= 8 --- inRange' (x,y) = inRange (x) && inRange (y) --- r x = (fst x + 1, snd x + 1) --- l x = (fst x - 1, snd x - 1) --- nexts x = diags' x --- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] --- -- down x = (fst x - 1, snd x - 1) --- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else --- -- up (r,c) = let u = (r+1,c+1) in u : up u - - ---mapDiag r c = undefined - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix ---import Numeric.LinearAlgebra -import System.Random -import Foreign.Storable - - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show, Eq) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -placeQueen (r,c) b = placeQueen' $ markAttacked b - where - placeQueen' b = setElem Qu (r,c) b - markAttacked b = rowAttacked $ colAttacked $ diagAttacked b - fX = (\_ x -> X) - rowAttacked b = mapRow fX r b - colAttacked b = mapCol fX c b - diagAttacked b = let d = diag r c - attack ap ab = setElem X ap ab - attackall [x] = attack x b - attackall (x:xs) = attack x (attackall xs) - in attackall d --- in last $ map (\p -> setElem X p b) d --- in last $ scanr (\p -> setElem X p) b - ---solve b = placeQueen (nextAvail b) b - -nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] - -solve b = solve $ solve $ solve $ placeQueen n b - where n = nextAvail b - - ---diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] -diag r c = let rl = [1..r] - rr = [r..8] - cu = [1..c] - cd = [c..8] - in zip rl cu ++ zip rr cd ++ - zip (reverse rl) cd ++ zip (reverse rr) cu - - - - --- diag (r,c) b = --- where l = (r-1,c-1) --- r = (r+1,c+1) --- lowbound = 1 --- highbound = 8 - - ---initBoard = (8><8) $ repeat O - ---firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] - --- firstOpen b = let --- elem x y = b ! (x, y) --- in map - --- nextOpen b = - --- solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b - - - --- diags p = let r = r p --- l = l p --- in p : inRange r --- where inRange x = x >= 1 && x <= 8 --- inRange' (x,y) = inRange (x) && inRange (y) --- r x = (fst x + 1, snd x + 1) --- l x = (fst x - 1, snd x - 1) --- nexts x = diags' x --- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] --- -- down x = (fst x - 1, snd x - 1) --- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else --- -- up (r,c) = let u = (r+1,c+1) in u : up u - - ---mapDiag r c = undefined - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 diff --git a/.stack-work/intero/intero38150Eh-TEMP.hs b/.stack-work/intero/intero38150Eh-TEMP.hs deleted file mode 100644 index e69de29..0000000 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -firstOpen b = let - elem x y = b ! (x, y) - in map - -nextOpen b = - -solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b --- placeQueen r c b = board --- where --- fX = (\ _ -> X) --- rowAttacked = mapRow fX r --- colAttacked = mapCol fx c --- queen = setElem Qu (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - -solve = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X | Qu | O deriving (Show) ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b -placeQueen r c b = board - where - fX = (\ _ -> X) - rowAttacked = mapRow fX r - colAttacked = mapCol fx c - queen = setElem Qu (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = - -solve = - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix -import System.Random - -data Square = X | Q deriving (Show) ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> X ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b -placeQueen r c b = setElem Q (r,c) b - ---placeAll = repeat 8 placeQueen - -winnable = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 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 @@ -module Main where - -import Control.Lens -import Linear.V2 -import Linear.V3 -import Data.Matrix ---import Numeric.LinearAlgebra -import System.Random -import Foreign.Storable - - -data Square = X -- Attacked - | Qu -- Queen - | O -- Open/available - deriving (Show, Eq) - - ---board = V3 <$> [0..8] <*> [0..8] <*> [0] ---board = [(r,c,X) | r <- [0..8], c <- [0..8] ] - -lo8 = [0..8] -- list of 8 -initBoard = matrix 8 8 $ \_ -> O - -placeQueen (r,c) b = placeQueen' $ markAttacked b - where - placeQueen' b = setElem Qu (r,c) b - markAttacked b = rowAttacked $ colAttacked $ diagAttacked b - fX = (\_ x -> X) - rowAttacked b = mapRow fX r b - colAttacked b = mapCol fX c b - diagAttacked b = let d = diag r c - attack ap ab = setElem X ap ab - attackall [x] = attack x b - attackall (x:xs) = attack x (attackall xs) - in attackall d --- in last $ map (\p -> setElem X p b) d --- in last $ scanr (\p -> setElem X p) b - ---solve b = placeQueen (nextAvail b) b - -nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] - --- solve b = placeQueen n --- where n = nextAvail b --- next = placeQueen n --- solve' = - --- solve b = --- where solve' b = (\n = placeQueen $ nextAvail b) - -solve b = second - where first = placeQueen (nextAvail b) b - second = placeQueen (nextAvail first) first - -solve' b = s (nA b) b - where s n b = placeQueen n b - nA b = nextAvail b - - ---diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] -diag r c = let rl = [1..r] - rr = [r..8] - cu = [1..c] - cd = [c..8] - in zip rl cu ++ zip rr cd ++ - zip (reverse rl) cd ++ zip (reverse rr) cu - -diag' p = where - maxB = 8 - minB = 1 - u = (+1) - d = (-1) - r = u - l = d - ur = (u fst, r snd) - ul = (u fst, l snd) - dr = (d fst, r snd) - dl = (d fst, l snd) - - - - --- diag (r,c) b = --- where l = (r-1,c-1) --- r = (r+1,c+1) --- lowbound = 1 --- highbound = 8 - - ---initBoard = (8><8) $ repeat O - ---firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] - --- firstOpen b = let --- elem x y = b ! (x, y) --- in map - --- nextOpen b = - --- solve = let board = initBoard - ---avail r c b = - ---rowOccupied r b = any (== Q) $ getRow r b - - - --- diags p = let r = r p --- l = l p --- in p : inRange r --- where inRange x = x >= 1 && x <= 8 --- inRange' (x,y) = inRange (x) && inRange (y) --- r x = (fst x + 1, snd x + 1) --- l x = (fst x - 1, snd x - 1) --- nexts x = diags' x --- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] --- -- down x = (fst x - 1, snd x - 1) --- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else --- -- up (r,c) = let u = (r+1,c+1) in u : up u - - ---mapDiag r c = undefined - ---placeAll = repeat 8 placeQueen - -winnable = undefined - -nextOpen board = undefined - --- placeQueen r c = - ---b = getE - ---placeQueen r c b = b ^. - --- rand = do --- g <- newStdGen --- print $ take 8 $ (randomRs (0, 8) g) - - --- try r c = let next b = placeQueen r c b --- in next initBoard - --- try' p = let next b = p b --- in next initBoard - - ---res = [ try x y | x <- lo8, y <- lo8 ] - -main :: IO () -main = do - 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 -- cgit v1.2.3