master
 1# frozen_string_literal: true
 2
 3def assert_equal(x, y)
 4  raise [x, y].inspect unless x == y
 5end
 6
 7class Solution
 8  def self.run(string)
 9    max, current = 0, 0
10
11    0.upto(string.size - 1) do |i|
12      if string[i] == string[i-1]
13        max = maximum(max, current)
14        current = 0
15      end
16      current += 1
17    end
18
19    maximum(max, current)
20  end
21
22  def self.maximum(x, y)
23    x > y ? x : y
24  end
25end
26
27assert_equal Solution.run('abrkaabcdefghijjxxx'), 10
28assert_equal Solution.run('aaabcd'), 4
29puts "YAY!"
30
31# step 1. understand the problem
32# step 2. pick a solution
33# step 3. write the solution