Skip to content

Instantly share code, notes, and snippets.

@recursivecurry
Created February 11, 2014 04:02
Show Gist options
  • Save recursivecurry/8929073 to your computer and use it in GitHub Desktop.
Save recursivecurry/8929073 to your computer and use it in GitHub Desktop.
introduction to functional programming - ex 3.3.12
module Score where
import Data.List
cow :: [Char] -> [Char] -> Int
cow sol input = length [1 | (x, y) <- zip sol input, x==y]
bull :: [Char] -> [Char] -> Int
bull sol input = length sol - length (sol \\ input)
score :: [Char] -> [Char] -> (Int, Int)
score sol input = (cow sol input, bull sol input - cow sol input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment