-//two :: [([Char],[Int])] a [[Int]] -> [[[String]]]
-two fields myticket nearby = (\x->proc x x [] []) $ map (foldr1 intersect) $ transpose $ map (collectConstraints fields) $ filter (valid fields) nearby
+two :: [([Char], [Int])] [Int] [[Int]] -> Int
+two fields myticket nearby
+ // Translate to numbers and multiply
+ = prod $ zipWith (\i [s]->if (startsWith ['departure'] s) i 1) myticket
+ // iteratively find all singletons and apply constraint
+ $ proc []
+ // Transpose and merge all fieldconstraints
+ $ map (\[x:xs]->foldr intersect x xs) $ transpose
+ // Remove all invalid fields
+ $ map (collectConstraints fields)
+ // Remove all invalid tickets
+ $ filter (valid fields) nearby