Created
September 17, 2014 16:04
-
-
Save pwnall/d47582382fa69d2a6cd8 to your computer and use it in GitHub Desktop.
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
def no_repeats(year_start, year_end) | |
no_repeats=[] | |
(year_start..year_end).each do |yr| | |
no_repeats<<yr if no_repeat?(yr) | |
end | |
no_repeats | |
end | |
def no_repeat?(year) | |
num_seen=[] | |
year.to_s.each_char do |num| | |
if num_seen.include?(num) | |
return false | |
else | |
num_seen<<num | |
end | |
end | |
return true | |
end | |
puts no_repeats(1980,1990); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment