codewars
This commit is contained in:
1 parent
0980afcc33
commit
1bf550a752
1 file changed
+16
-11
@@ -1,16 +1,21 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
class Test
|
||||
def initialize(fruit)
|
||||
@fruit = fruit
|
||||
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
|
||||
|
||||
def hello
|
||||
name = "Bob"
|
||||
puts "Hello #{name} !"
|
||||
end
|
||||
num = 123
|
||||
puts digits(num)
|
||||
|
||||
def eat
|
||||
puts "#{@fruit}"
|
||||
end
|
||||
end
|
||||
# Additionner avec > que lui puis donner la somme
|
||||
# 1 + 2 = 3
|
||||
# 1 + 3 = 4
|
||||
# 2 + 3 = 5
|
||||
Reference in new issue
Block a user