diff options
| author | nekineki <nekineki@nekineki.net> | 2024-12-05 09:04:36 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2024-12-05 09:30:21 +0100 |
| commit | 97501bb2b1c876f92bc44ea53ba4686d15145b60 (patch) | |
| tree | 2a04125852600fe9455e53c46ea2a47010202eb5 | |
| parent | f257f268f3f13dadc09eb03b96b4f53f7e9b46ff (diff) | |
update day05
| -rw-r--r-- | 2024/day05.rs | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/2024/day05.rs b/2024/day05.rs index bf4303a..0d9759b 100644 --- a/2024/day05.rs +++ b/2024/day05.rs @@ -15,13 +15,6 @@ fn is_valid(update: &Vec<usize>, rules: &Vec<(usize, usize)>) -> bool { } } } - if n == r { - if let Some(pl) = update.iter().position(|a| a == l) { - if pl > i { - return false; - } - } - } } } @@ -42,15 +35,6 @@ fn make_valid(update: &Vec<usize>, rules: &Vec<(usize, usize)>) -> Vec<usize> { } } } - if n == *r { - if let Some(pl) = uv.iter().position(|a| a == l) { - if i < pl { - uv[pl] = n; - uv[i] = *l; - break; - } - } - } } } @@ -91,7 +75,7 @@ fn main() { if ret { res1 += u[u.len() / 2]; } else { - let mut uv = make_valid(&u, &rules); + let mut uv = u; while !is_valid(&uv, &rules) { uv = make_valid(&uv, &rules); } |
