Skip to content

Instantly share code, notes, and snippets.

@eccstartup
Created July 26, 2015 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eccstartup/5ccdb37a9772e1b81108 to your computer and use it in GitHub Desktop.
Save eccstartup/5ccdb37a9772e1b81108 to your computer and use it in GitHub Desktop.
import Data.List
mylines = ["ABEHKNQaqz+/","ACFILORclsx","ADGJMPZVih","BCD","EFG","HIJ","KLM","NOP","HLP","K1O","M2O","OQ","OWXYZ","QRSTUV","abcdefgh","aijklmnop","qrstuv","zyx","+-*","PWRbjq","PXSckry-/","PYTdmtx","ZUehuw","Vfov","igp"]
mypoints = "abcdefghijk"
connected a b = belong [a,b] mylines
onaline a b c = belong [a,b,c] mylines
belong x xs = any (\y -> sub x y) xs
sub x y = all (\z -> elem z y) x
triangle [a, b, c] = connected a b && connected a c && connected b c && not (onaline a b c)
triplepoints = nub [sort [a,b,c] | a <- mypoints, b <- mypoints, b /= a, c <- mypoints, c /= a, c /= b]
main = putStrLn $ show $ length $ filter triangle triplepoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment