Created
February 28, 2011 03:06
-
-
Save msakai/846879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type S = ((Int,Int),(Int,Int),(Int,Int)) | |
guess :: S -> S | |
guess ((a1,a2),(b1,b2),(c1,c2)) = | |
case (a1+b1) `compare` (b2+c1) of | |
EQ -> | |
if b1 < b2 | |
then ((100,99),(99,100),(99,100)) | |
else ((99,100),(100,99),(100,99)) | |
LT -> | |
case (a1+c1) `compare` (a2+c2) of | |
EQ -> ((99,100),(99,100),(100,99)) | |
LT -> ((99,100),(99,100),(99,100)) | |
GT -> ((100,99),(99,100),(100,99)) | |
GT -> | |
case (a1+c1) `compare` (a2+c2) of | |
EQ -> ((100,99),(100,99),(99,100)) | |
LT -> ((99,100),(100,99),(99,100)) | |
GT -> ((100,99),(100,99),(100,99)) | |
test :: S -> Bool | |
test s = guess s == s | |
testAll :: Bool | |
testAll = and [test (as,bs,cs) | as <- xs, bs <- xs, cs <- xs] | |
where xs = [(99,100),(100,99)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment