diff --git a/plus_one.rb b/plus_one.rb new file mode 100644 index 0000000..38c41e8 --- /dev/null +++ b/plus_one.rb @@ -0,0 +1,15 @@ +def plus_one(digits) + puts digits + str = "" + digits.each_index { |i| + puts digits[i] + str = str + digits[i].to_s + puts "this is #{str}" + } + x = str.to_i + x = x+1 + return x.to_s.scan(/./).map {|e| e.to_i } +end + +x = [4,3,2,1] +puts plus_one(x) \ No newline at end of file