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