Skip to content

Commit

Permalink
plus one
Browse files Browse the repository at this point in the history
  • Loading branch information
a-abdellatif98 committed Jun 8, 2022
1 parent e97f39c commit 0cb10a4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions plus_one.rb
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 0cb10a4

Please sign in to comment.