-- Compute the answer between target and guess.
response :: [String] -> [String] -> (Int,Int,Int)
response target guess = (mPitches,mNotes,mOctave)
    where   targetSet = Set.fromList target
            guessSet  = Set.fromList guess
            intersection = Set.intersection targetSet guessSet
            mPitches = Set.size intersection
            diffTarget = Set.difference targetSet intersection
            diffGuess  = Set.difference guessSet intersection
            targetNotes = nub $ map head $ Set.toList diffTarget 
            guessNotes = nub $ map head $ Set.toList diffGuess
            mNotes = foldr (\x acc -> 
                    if elem x guessNotes 
                    then acc + 1 else acc) 0 targetNotes
            targetOctaves = sort $ map tail $ Set.toList diffTarget
            guessOctaves = sort $ map tail $ Set.toList diffGuess
            mOctave = computeOctaves targetOctaves guessOctaves

-- Compute how many octaves are same.
response :: [String] -> [String] -> (Int,Int,Int)
response target guess = (mPitches,mNotes,mOctave)
    where   targetSet = Set.fromList target
            guessSet  = Set.fromList guess
            intersection = Set.intersection targetSet guessSet
            mPitches = Set.size intersection
            diffTarget = Set.difference targetSet intersection
            diffGuess  = Set.difference guessSet intersection
            targetNotes = nub $ map head $ Set.toList diffTarget 
            guessNotes = nub $ map head $ Set.toList diffGuess
            mNotes = foldr (\x acc -> 
                    if elem x guessNotes 
                    then acc + 1 else acc) 0 targetNotes
            targetOctaves = sort $ map tail $ Set.toList diffTarget
            guessOctaves = sort $ map tail $ Set.toList diffGuess
            mOctave = computeOctaves targetOctaves guessOctaves

-- Compute how many octaves are same.
response target guess = (mPitches,mNotes,mOctave)
    where   targetSet = Set.fromList target
            guessSet  = Set.fromList guess
            intersection = Set.intersection targetSet guessSet
            mPitches = Set.size intersection
            diffTarget = Set.difference targetSet intersection
            diffGuess  = Set.difference guessSet intersection
            targetNotes = nub $ map head $ Set.toList diffTarget 
            guessNotes = nub $ map head $ Set.toList diffGuess
            mNotes = foldr (\x acc -> 
                    if elem x guessNotes 
                    then acc + 1 else acc) 0 targetNotes
            targetOctaves = sort $ map tail $ Set.toList diffTarget
            guessOctaves = sort $ map tail $ Set.toList diffGuess
            mOctave = computeOctaves targetOctaves guessOctaves

-- Compute how many octaves are same.