fork download
  1. n=gets.to_i
  2. s=gets.chomp.split("")
  3. ans=4
  4. s.each_cons(4){|s1,s2,s3,s4|
  5.  
  6. t=0
  7. t+=1 if s1!="A"
  8. t+=1 if s2!="C"
  9. t+=1 if s3!="P"
  10. t+=1 if s4!="C"
  11. ans=[ans,t].min
  12. }
  13. puts ans
Success #stdin #stdout 0.01s 8024KB
stdin
9
PPCACPCAA
stdout
0