Last active
September 22, 2018 05:14
-
-
Save Judrummer/4c4a66df1e1844b9252e196d5d2feeff to your computer and use it in GitHub Desktop.
Hangman the series kata (https://forums.bigbears.io/t/hangman-the-series-basic-function/368)
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
fun hangman(secretWord: String, letters: List<Char>): Boolean { | |
val remaingChars = secretWord.toCharArray().toMutableList() | |
var score = 7 | |
var i = 0 | |
while (remaingChars.size > 0 && i < letters.size && score > 0) { | |
if (!remaingChars.remove(letters[i])) score-- | |
i++ | |
} | |
return score > 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment