Created
June 8, 2017 23:30
-
-
Save kenmazaika/2dc850deb442dccca2617ca88d87699e to your computer and use it in GitHub Desktop.
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_number(sequence) | |
| numbers = sequence.split.sort | |
| prev = 0 | |
| numbers.each do |number| | |
| puts number.inspect | |
| if number.to_i.to_s != number | |
| return 1 | |
| end | |
| if number.to_i != prev + 1 | |
| return prev + 1 | |
| end | |
| prev = prev + 1 | |
| end | |
| return 0 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment