Skip to content

Instantly share code, notes, and snippets.

@pwnall
Created September 17, 2014 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwnall/d47582382fa69d2a6cd8 to your computer and use it in GitHub Desktop.
Save pwnall/d47582382fa69d2a6cd8 to your computer and use it in GitHub Desktop.
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