new exercise from codewars
This commit is contained in:
1 parent
594d2bdd12
commit
b2cef2f27c
2 files changed
+23
-18
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
def digits(num)
|
||||
result = []
|
||||
numbers = num.to_s.split('').map { |n| n.to_i }
|
||||
numbers.each_with_index do |number, index|
|
||||
following = numbers[(index + 1)..]
|
||||
following.each do |other|
|
||||
result << number + other
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
num = 123
|
||||
puts digits(num)
|
||||
|
||||
# Additionner avec > que lui puis donner la somme
|
||||
# 1 + 2 = 3
|
||||
# 1 + 3 = 4
|
||||
# 2 + 3 = 5
|
||||
@@ -1,21 +1,5 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
def digits(num)
|
||||
result = []
|
||||
numbers = num.to_s.split('').map { |n| n.to_i }
|
||||
numbers.each_with_index do |number, index|
|
||||
following = numbers[(index + 1)..]
|
||||
following.each do |other|
|
||||
result << number + other
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
text = "Bonjour Ruby"
|
||||
|
||||
num = 123
|
||||
puts digits(num)
|
||||
|
||||
# Additionner avec > que lui puis donner la somme
|
||||
# 1 + 2 = 3
|
||||
# 1 + 3 = 4
|
||||
# 2 + 3 = 5
|
||||
p text.empty?
|
||||
Reference in new issue
Block a user