Created
February 11, 2014 04:02
-
-
Save recursivecurry/8929073 to your computer and use it in GitHub Desktop.
introduction to functional programming - ex 3.3.12
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
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