Skip to content

Instantly share code, notes, and snippets.

@radralph
Created April 28, 2017 08:42
Show Gist options
  • Save radralph/d403e534e09291ada896d8d1cd38952e to your computer and use it in GitHub Desktop.
Save radralph/d403e534e09291ada896d8d1cd38952e to your computer and use it in GitHub Desktop.
task :solution do
digits = rand(100000..100000000).to_s.split(//)
#digits = "283910".to_s.split(//)
mSize, allResult = digits.size, []
digits.each_with_index do |x, index|
temp = []
index.to_i.upto(mSize) do |y|
temp << digits[y].to_i
if temp.size.eql? 5
allResult << temp.join("")
temp = []
break
end
end
end
puts ""
puts "Base Number:"
puts digits.join()
puts "-------"
puts "All Combinations:"
puts allResult
puts "-------"
puts "Largest Number:"
puts allResult.max
puts ""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment