Created
August 17, 2012 14:35
-
-
Save myokoym/3379205 to your computer and use it in GitHub Desktop.
Problem038
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
#! ruby | |
ans = [] | |
1.upto(0 / 0.0) do |n| | |
a = Array.new(2) { n }.map.with_index {|v, i| (v * (i + 1)).to_s }.join | |
break if a.size > 9 | |
2.upto(0 / 0.0) do |m| | |
a = Array.new(m) { n }.map.with_index {|v, i| (v * (i + 1)).to_s }.join | |
break if a.size > 9 | |
next unless a.size == 9 | |
if a.split(//).sort.join == (1..9).to_a.join | |
ans << a | |
end | |
end | |
end | |
p ans | |
p ans.max |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment