[2021][ruby][18.x] small refactoring

pull/2/head
Alpha Chen 3 years ago
parent 2196242eea
commit 289d452904

@ -62,15 +62,11 @@ def explode(s, pair_range)
end end
class Array class Array
def magnitude def magnitude = 3*self[0].magnitude + 2*self[1].magnitude
3*self[0].magnitude + 2*self[1].magnitude
end
end end
class Integer class Integer
def magnitude def magnitude = self
self
end
end end
# sum = ARGF.read.split("\n").reject(&:empty?).inject {|sum,num| add(sum, num) } # sum = ARGF.read.split("\n").reject(&:empty?).inject {|sum,num| add(sum, num) }

Loading…
Cancel
Save