1
// Mfw I can't do a q. in > 12 lines:4
pub fn nearest_palindromic(s: String) -> String {5
let num = s.parse::<i64>().unwrap();8
let half = s[0..(len + 1) / 2].parse::<i64>().unwrap();10
let mut candidates = vec![10i64.pow(len as u32) + 1, 10i64.pow(len as u32 - 1) - 1];12
for &i in &[half - 1, half, half + 1] {13
let mut cand_str = i.to_string();14
let rev = cand_str.chars().rev().collect::<String>();20
cand_str.push_str(&rev);21
candidates.push(cand_str.parse().unwrap());26
.filter(|&c| c != num)27
.min_by_key(|&c| ((c - num).abs(), c))