mirror of
https://github.com/wezm/advent-of-code.git
synced 2024-12-18 10:19:55 +00:00
Rename Memory to Computer
This commit is contained in:
parent
102a98fc82
commit
b53033b15d
2 changed files with 5 additions and 5 deletions
|
@ -4,7 +4,7 @@ use std::{fs, io};
|
|||
fn main() -> io::Result<()> {
|
||||
let input = fs::read_to_string("input/day5.txt")?;
|
||||
let mut data = input::read_separated_line(',', &input)?;
|
||||
let mut program = computer::Memory::new(&mut data);
|
||||
let mut program = computer::Computer::new(&mut data);
|
||||
|
||||
program.run(None, None);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ enum Mode {
|
|||
Address,
|
||||
}
|
||||
|
||||
pub struct Memory<'a> {
|
||||
pub struct Computer<'a> {
|
||||
mem: &'a mut [i32],
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,9 @@ fn decode(mut instruction: i32) -> Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Memory<'a> {
|
||||
impl<'a> Computer<'a> {
|
||||
pub fn new(mem: &'a mut [i32]) -> Self {
|
||||
Memory { mem }
|
||||
Computer { mem }
|
||||
}
|
||||
|
||||
fn read(&self, value: i32, mode: Mode) -> i32 {
|
||||
|
@ -191,7 +191,7 @@ mod tests {
|
|||
fn test_day2() {
|
||||
let input = fs::read_to_string("input/day2.txt").unwrap();
|
||||
let mut data = input::read_separated_line(',', &input).unwrap();
|
||||
let mut program = Memory::new(&mut data);
|
||||
let mut program = Computer::new(&mut data);
|
||||
|
||||
// Check that day2 still works wirh run through this implementation
|
||||
program.run(Some(12), Some(2));
|
||||
|
|
Loading…
Reference in a new issue