clean up 16
This commit is contained in:
@@ -5,3 +5,6 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "*"
|
itertools = "*"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|||||||
+5
-7
@@ -19,16 +19,14 @@ fn main() {
|
|||||||
fn calculate_checksum(length: usize) {
|
fn calculate_checksum(length: usize) {
|
||||||
let mut a = INPUT.to_string();
|
let mut a = INPUT.to_string();
|
||||||
while a.len() < length {
|
while a.len() < length {
|
||||||
let mut b = a.clone();
|
let b = a.clone();
|
||||||
b = b
|
let b_chars = b.chars().rev().map(|c| if c == '0' { '1' } else { '0' });
|
||||||
.chars()
|
|
||||||
.rev()
|
|
||||||
.map(|c| if c == '0' { '1' } else { '0' })
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut result = a.clone();
|
let mut result = a.clone();
|
||||||
result.push('0');
|
result.push('0');
|
||||||
result.push_str(&b);
|
for ch in b_chars {
|
||||||
|
result.push(ch);
|
||||||
|
}
|
||||||
a = result;
|
a = result;
|
||||||
}
|
}
|
||||||
a.truncate(length);
|
a.truncate(length);
|
||||||
|
|||||||
Reference in New Issue
Block a user