Created
October 2, 2016 08:37
-
-
Save anonymous/95678c78335d3e0393ec0d57bf519fa3 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
class Test1 | |
def solution(a, b) | |
max = 100000000 | |
if a >= 0 && b >= 0 | |
aArray = a.to_s.split('').map(&:to_i) | |
bArray = b.to_s.split('').map(&:to_i) | |
cArray = Array.new | |
aArray.each do |el| | |
cArray = cArray.push(aArray[el-1]) | |
cArray = cArray.push(bArray[el-1]) | |
end | |
c = cArray.join.to_i | |
if c > max | |
puts "no ok" | |
return -1 | |
else | |
puts c | |
return c | |
end | |
else | |
return -1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment