The no_repeats method is to check if any of the years in the range have repeating number. I paired it with a no_repeat? method that checks individual years.
def no_repeats(year_start, year_end)
no_repeat_years = [year_start..year_end].select { |year| no_repeat?(year) }
end
def no_repeat?(year)
numbers = year.split("")
numbers.each do |n|
if numbers.count(n) > 1
return false
end
end
return true
end
When I try to run the no_repeats, I'm getting the following error:
undefined method `split' for 1980..2000:Range (NoMethodError)
Why is the entire range getting plugged into the helper function?