Commit 665f84c
Changed files (1)
2020
08
11
2020/08/11/main.rb
@@ -10,18 +10,23 @@ class Solution
0.upto(string.size - 1) do |i|
if string[i] == string[i-1]
- max = max > current ? max : current
+ max = maximum(max, current)
current = 0
end
current += 1
end
- max > current ? max : current
+ maximum(max, current)
+ end
+
+ def self.maximum(x, y)
+ x > y ? x : y
end
end
assert_equal Solution.run('abrkaabcdefghijjxxx'), 10
assert_equal Solution.run('aaabcd'), 4
+puts "YAY!"
# step 1. understand the problem
# step 2. pick a solution