Last active
March 19, 2020 18:26
-
-
Save lexruee/ac15e5d0337bcc1b4cc4bf61e275750e to your computer and use it in GitHub Desktop.
Find the missing letter in the passed letter range and return it.
This file contains hidden or 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
def find_missing_letter(range) | |
chars = range.chars | |
max_char = chars.max | |
min_char = chars.min | |
missing_chars = (min_char..max_char).to_a - chars | |
missing_chars.first | |
end | |
p find_missing_letter "abde" | |
p find_missing_letter "abcdefgijk" | |
p find_missing_letter "abcdef" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment