fork download
  1. def f11102(s)
  2. %w(g c p).map {|c| s.count(c)}.cycle.each_cons(3).take(3).map {|(a, b, c)| c == 0 && 0 < b ? a : 0}.max
  3. end
  4. a = %w(gccgc ggggggg cppcppppccpppppc cppcppppccpgpppc)
  5. p a.map {|s| [s, (f11102 s)]}
  6.  
Success #stdin #stdout 0.01s 6100KB
stdin
Standard input is empty
stdout
[["gccgc", 2], ["ggggggg", 0], ["cppcppppccpppppc", 5], ["cppcppppccpgpppc", 0]]