Skip to content

Instantly share code, notes, and snippets.

@negamorgan
Created March 17, 2014 21:02
Show Gist options
  • Save negamorgan/9608303 to your computer and use it in GitHub Desktop.
Save negamorgan/9608303 to your computer and use it in GitHub Desktop.
Largest 5 digit number in a series
def solution(digits)
group_by_five(digits).max
end
def group_by_five(digits)
digits.split("")[0..-5].map.with_index do |digit, i|
"#{digit}#{digits[i+1]}#{digits[i+2]}#{digits[i+3]}#{digits[i+4]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment