You are viewing a single comment's thread. Return to all comments →
My rust solution:
fn separateNumbers(s: &str) { let mut i = 0; 'main: while i < s.len() / 2 { i += 1; let x: i64 = s[..i].parse().unwrap(); let mut next = (x + 1).to_string(); if s[i..(i + next.len())] == next { let mut tmp = &s[(i + next.len())..]; while !tmp.is_empty() { next = (next.parse::<i64>().unwrap() + 1).to_string(); if &tmp[..next.len().min(tmp.len())] != next { continue 'main; } tmp = &tmp[next.len()..]; } println!("YES {x}"); return; } } println!("NO");
Seems like cookies are disabled on this browser, please enable them to open this website
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
My rust solution: