Skip to content

Commit

Permalink
Do it
Browse files Browse the repository at this point in the history
  • Loading branch information
UnarmedLad committed Sep 19, 2014
1 parent 74c0ff2 commit e9cedcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions Balance2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module Balance
where

import Data.List
import Debug.Trace
myShow xs = traceShow xs xs

data Coin = Light | Normal deriving (Eq,Show,Bounded,Enum)
data Feedback = Leftbound | Balanced | Rightbound deriving (Eq,Show)
Expand Down Expand Up @@ -43,7 +41,7 @@ exercise6alist n xs = map (\ (a,b) -> (a, group b)) $ [(maybeGuess, [reaction ma

exercise6aplay :: Int -> Pattern -> [Pattern] -> Int -> Int
exercise6aplay _ secret (x:[]) i = if x == secret then i else -1
exercise6aplay n secret xs i = exercise6aplay n secret (guessing secret (myShow $ exercise6amin $ exercise6amax $ exercise6alist n xs) xs) (i+1)
exercise6aplay n secret xs i = exercise6aplay n secret (guessing secret (exercise6amin $ exercise6amax $ exercise6alist n xs) xs) (i+1)

exercise6a :: Int -> Pattern -> Int
exercise6a n secret = exercise6aplay n secret firstList 0 where firstList = makeList [Light,Normal] n
Expand All @@ -57,7 +55,7 @@ exercise6bentropy xs = map (\ (a,b) -> (a,sum $ map (\ x -> fromIntegral x * (lo

exercise6bplay :: Int -> Pattern -> [Pattern] -> Int -> Int
exercise6bplay _ secret (x:[]) i = if x == secret then i else -1
exercise6bplay n secret xs i = exercise6bplay n secret (guessing secret (myShow $ exercise6bmin $ exercise6bentropy $ exercise6alist n xs) xs) (i+1)
exercise6bplay n secret xs i = exercise6bplay n secret (guessing secret (exercise6bmin $ exercise6bentropy $ exercise6alist n xs) xs) (i+1)

exercise6b :: Int -> Pattern -> Int
exercise6b n secret = exercise6bplay n secret firstList 0 where firstList = makeList [Light,Normal] n
Expand Down
2 changes: 1 addition & 1 deletion Mastermind2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ makeList xs n = [[x] ++ y | x <- xs, y <- makeList xs $ n-1]
firstList = makeList [Red,Yellow,Blue,Green,Orange] 4

guessing :: Pattern -> Pattern -> [Pattern] -> [Pattern]
guessing secret guess xs = traceShow guess filter (\x -> reaction x guess == reaction secret guess) xs
guessing secret guess xs = filter (\x -> reaction x guess == reaction secret guess) xs


exercise1play :: Pattern -> [Pattern] -> Int -> Int
Expand Down

0 comments on commit e9cedcb

Please sign in to comment.