mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 13:20:32 +01:00
Remove code duplication.
This commit is contained in:
@@ -45,15 +45,12 @@ impl Day12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_input(&mut self, input: &mut Read) -> State {
|
fn read_input(&mut self, input: &mut Read) -> State {
|
||||||
let mut state = Vec::new();
|
let state;
|
||||||
let mut reader = BufReader::new(input);
|
let mut reader = BufReader::new(input);
|
||||||
{
|
{
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
reader.read_line(&mut line).unwrap();
|
reader.read_line(&mut line).unwrap();
|
||||||
|
state = state_from_string(&line["initial state:".len()..line.len()].trim(), 0);
|
||||||
for (idx, c) in line.trim().chars().skip("initial state: ".len()).enumerate() {
|
|
||||||
state.push((idx as i64, char_bool(c)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
|
|||||||
Reference in New Issue
Block a user