When you have regex, everything looks like a haystack.
Nearly solved pt2 by accident in pt1. Just showing the invalid checks, rest of the code is uninteresting.
fn check_invalid(p0: usize) -> bool {
let str = format!("{}", p0);
let len = str.len();
if len % 2 == 1 {
return false;
}
let len = len / 2;
str[0..len] == str[len..]
}
fn check_invalid2(p0: usize) -> bool {
let str = format!("{}", p0);
let re = Regex::new(r"^([0-9]{1,})\1{1,}$").unwrap();
if re.is_match(str.as_bytes()).unwrap() {
return true;
}
false
}
edit: The bot worked as well! With some slight human intervention. Tomorrow might be automatic if we are lucky.