Created
March 2, 2015 19:36
-
-
Save Kah0ona/15f3663d0b7846d3f9f6 to your computer and use it in GitHub Desktop.
solve a flippo by using t [2,2,7,1]
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
import Data.List | |
t :: [Double] -> [[Char]] | |
t f = | |
let | |
perms = permutations f | |
opers = [("+", (+)), ("-", (-)), ("*", (*)), ("/" ,(/))] | |
in | |
["(((" ++ (show $ truncate a) ++ n1 ++ (show $ truncate b) ++ ")" ++ n2 ++ (show $ truncate c) ++ ")" ++ n3 ++ (show $ truncate d) ++ ")" | | |
[a ,b ,c ,d ] <- perms, | |
(n1, op1) <- opers, (n2, op2) <- opers, (n3,op3) <- opers, | |
(op3 (op2 (op1 a b) c) d) == 24] | |
allflippos = [[a,b,c,d] | a <- [0..9], b <- [0..9], c <- [0..9], d <-[0..9], | |
length (t [a,b,c,d]) > 0] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment