# frozen_string_literal: true def assert_equal(x, y) raise [x, y].inspect unless x == y end class Solution def self.run(string) max, current = 0, 0 0.upto(string.size - 1) do |i| if string[i] == string[i-1] max = maximum(max, current) current = 0 end current += 1 end 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 # step 3. write the solution