Wordle comparison: Difference between revisions

Content added Content deleted
(→‎{{header|Haskell}}: Added a version in Haskell.)
Line 163: Line 163:
amber
amber
(charCounts residue)
(charCounts residue)
(zip matches guess)
(zip guess matches)


green :: String -> (Char, Char) -> (String, Int)
green :: String -> (Char, Char) -> (String, Int)
Line 170: Line 170:
| otherwise = (t : residue, 0)
| otherwise = (t : residue, 0)


amber :: Tally -> (Int, Char) -> (Tally, Int)
amber :: Tally -> (Char, Int) -> (Tally, Int)
amber tally (2, _) = (tally, 2)
amber tally (_, 2) = (tally, 2)
amber tally (_, c)
amber tally (c, 0)
| 0 < fromMaybe 0 (M.lookup c tally) =
| 0 < fromMaybe 0 (M.lookup c tally) =
(M.adjust pred c tally, 1)
(M.adjust pred c tally, 1)