This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // TBD | |
| // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{BufReader, BufRead}; | |
| use std::fs::File; | |
| use std::collections::HashMap; | |
| struct Machine { | |
| prog_ptr: i64, | |
| relative_base: i64, | |
| program: Vec<i64>, | |
| input: Vec<i64>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{BufReader, BufRead}; | |
| use std::fs::File; | |
| use std::collections::HashMap; | |
| struct Machine { | |
| prog_ptr: i64, | |
| relative_base: i64, | |
| program: Vec<i64>, | |
| input: Vec<i64>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Part 2 is pure brute force. Compiled in release mode it still takes | |
| // about 1 hour or so to get to the answer. There is of course a better way | |
| // to do it which could be looked at later, time permitting. | |
| // | |
| use std::collections::HashMap; | |
| fn main() { | |
| let prod = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{BufReader, BufRead}; | |
| use std::fs::File; | |
| use std::collections::HashMap; | |
| struct Machine { | |
| prog_ptr: i64, | |
| relative_base: i64, | |
| program: Vec<i64>, | |
| input: Vec<i64>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // It was maybe not such a great idea (code-length wise) to represent | |
| // MoonSystem, Moon, Coordinates and so on with explicit structs. Could probably be done | |
| // in 1/4 of the lines with Vecs. | |
| // | |
| use std::collections::HashSet; | |
| fn main() { | |
| let mut moons = MoonSystem { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{BufReader, BufRead}; | |
| use std::fs::File; | |
| use std::collections::HashMap; | |
| struct Machine { | |
| prog_ptr: i64, | |
| relative_base: i64, | |
| program: Vec<i64>, | |
| input: Vec<i64>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This should be revised. It is super-ineffcient as it stands although it provides the correct answer in < 4 sec. | |
| // Maybe later wehen there is not a christmas party the same day. | |
| use std::io::{BufReader, BufRead}; | |
| use std::env; | |
| use std::fs::File; | |
| fn main() { | |
| let belt_size: usize = 21; | |
| let args: Vec<String> = env::args().collect(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{BufReader, BufRead}; | |
| use std::fs::File; | |
| fn main() { | |
| let program_file = "prog".to_string(); | |
| let program: Vec<i64> = load_program(&program_file); | |
| let mut machine = Machine { | |
| prog_ptr: 0, | |
| relative_base: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const INPUT: &str = "2222220220222222222220222222221221222222122221222220222122222022222222212221222210222222222020222202222222222220202222220022222222222222002222222022202222222220222222222221222222220220222222022222222221222122222022222222002221222220222222222222222222222222222222222222222222222222222222012222222222220222222220222222122221222220221222222222122221222222222122222022222222202221222212222222222220222222222222222221102222220222222222222222212222222222202222220221222222022222222222220221222222122221222221222022222022222222002222222200222222222221222222222222222220102222222122222222222222102222222122211222222221222222122222222222220222222222022221202222222122222122222222002222222201222222222222222212222222222222122222220222222222222222022222222222221222221220222222122222222221221221222222122222222222222122222222222222122222222222222222222221222212222222222221022222221122222222222222112222222022201222220222222222222222222222222220222222122220212221222022222022222222002222222202222222222021222202222 |