Created
April 28, 2017 08:42
-
-
Save radralph/d403e534e09291ada896d8d1cd38952e 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
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