Skip to content

Instantly share code, notes, and snippets.

@joseanpg
Created February 6, 2015 12:39
Show Gist options
  • Save joseanpg/da30414372bad7208f51 to your computer and use it in GitHub Desktop.
Save joseanpg/da30414372bad7208f51 to your computer and use it in GitHub Desktop.
helpingraf.hs
import Data.List
-- alphabil = [0,0,0,0,1,1,1,2,2,2]
-- alphanob = [0,0,0,0,3,3,3,4,4,4]
alphabil = [0,0,0,1,1,2,2]
alphanob = [0,0,0,3,3,4,4]
betabil = {-nub-} (permutations alphabil)
betanob = {-nub-} (permutations alphanob)
gamma = [(alphabil,v,w)| v <- betabil , w <- betabil]
{-
gamma = [(alphabil,v,w,x,y,z)| v <- betabil , w <- betabil
, x <- betanob , y <- betanob , z <- betanob ]
-}
condi1 :: ([Integer],[Integer],[Integer])->Bool
condi1 ([],[],[]) = True
condi1 (u:us,v:vs,w:ws)
| (u == 1 || u == 2) && (u == v || u == w) = False
| (v == 1 || v == 2) && v == w = False
| u == 0 && v == 0 && w == 0 = False
| otherwise = condi1 (us,vs,ws)
condi2 ([],[],[],[],[],[]) = True
condi2 (u:us,v:vs,w:ws,x:xs,y:ys,z:zs) =
if omega [u,v,w,x,y,z] 0 > 4 then False
else condi2 (us,vs,ws,xs,ys,zs)
where omega [] a = a
omega (x:xs) a = if x == 0 then omega xs (a+1)
else omega xs a
delta [] = putStrLn "FIN"
delta (x:xs) = if (condi1 x)
then putStrLn "---------------------" >> enjoy x >> delta xs
else delta xs
enjoy (x:xs,y:ys,z:zs) = print ( (show x) ++ (show y) ++ (show z)) >> enjoy (xs,ys,zs)
enjoy ([],[],[]) = return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment