Rust, 239239 234 bytes
|i:&str||i|{let mut r=vec![];for l in 1..i.len(){let(mut s,mut v)=(vec![0;l*2],vec![(0,0)]);for c in i.bytes(){s[c as usize%3&1]+=1-(c as i64%5&2);v.push((s[0],s[1]));s.rotate_left(2);}v.sort();v.dedup();r.push((!v.len(),l));}r.sort();r[0].1}
Ungolfed:
|i: &str||i| {
let mut r = vec![];
for l in 1..i.len() {
let (mut s, mut v) = (vec![0; l * 2], vec![(0, 0)]);
for c in i.bytes() {
s[c as usize % 3 & 1] += // %3 - bit 1 flips, s[0] or s[1]
1 - (c as i64 % 5 & 2); // %5 - bit 2 flips, 0 or 2
v.push((s[0], s[1]));
s.rotate_left(2);
}
v.sort();
v.dedup();
r.push((!v.len(), l)); // dirty negation to reverse tuple sort order
}
r.sort();
r[0].1
};
History:
- -5 by removing the type annotation for
i
(thanks @Aiden4)