mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 21:30:31 +01:00
Correct formatting.
This commit is contained in:
@@ -6,8 +6,8 @@ use std::io::Read;
|
||||
use regex::Regex;
|
||||
|
||||
use common::Solution;
|
||||
use cpu::CPU;
|
||||
use cpu::OpCode;
|
||||
use cpu::CPU;
|
||||
|
||||
pub struct Day16 {
|
||||
matcher: Regex,
|
||||
@@ -38,12 +38,27 @@ impl Day16 {
|
||||
found
|
||||
}
|
||||
|
||||
fn determine_options(&mut self, mut reader: &mut BufReader<&mut Read>) -> [HashSet<OpCode>; 16] {
|
||||
fn determine_options(
|
||||
&mut self,
|
||||
mut reader: &mut BufReader<&mut Read>,
|
||||
) -> [HashSet<OpCode>; 16] {
|
||||
let mut mappings: [HashSet<OpCode>; 16] = [
|
||||
HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(),
|
||||
HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(),
|
||||
HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(),
|
||||
HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
HashSet::new(),
|
||||
];
|
||||
let mut before = [0; 6];
|
||||
let mut op = [0; 4];
|
||||
@@ -54,11 +69,10 @@ impl Day16 {
|
||||
reader.read_line(&mut self.buf).unwrap_or(0);
|
||||
|
||||
if mappings[op[0] as usize].is_empty() {
|
||||
mappings[op[0] as usize].extend(OpCode::values()
|
||||
.filter(|x| x.is_valid(&op, &before, &after)));
|
||||
mappings[op[0] as usize]
|
||||
.extend(OpCode::values().filter(|x| x.is_valid(&op, &before, &after)));
|
||||
} else {
|
||||
for option in OpCode::values()
|
||||
.filter(|x| !x.is_valid(&op, &before, &after)) {
|
||||
for option in OpCode::values().filter(|x| !x.is_valid(&op, &before, &after)) {
|
||||
mappings[op[0] as usize].remove(&option);
|
||||
}
|
||||
continue;
|
||||
@@ -149,7 +163,6 @@ impl Solution for Day16 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use common::Solution;
|
||||
|
||||
Reference in New Issue
Block a user