DEV Community

Discussion on: Daily Challenge #60 - Find the Missing Letter

Collapse
 
aminnairi profile image
Amin • Edited

I also did use my algorithm in Elm. Here is the source-code for the inner logic function.

getMissingLetter : List Char -> Char -> Maybe Char
getMissingLetter letters nextCharacter =
    case letters of
        [] ->
            Nothing

        letter :: rest ->
            let
                characterCode =
                    Char.toCode letter

                nextCharacterCode =
                    Char.toCode nextCharacter
            in
            if characterCode /= nextCharacterCode then
                Just nextCharacter

            else
                getMissingLetter rest <| Char.fromCode <| nextCharacterCode + 1

I bet there could be a way to use it in Haskell or PureScript as well, but I'm more confortable using Elm for now.

And the testing is of course available here on Ellie App.