This file contains 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::hash::Hash; | |
use std::collections::{HashMap, VecDeque}; | |
use std::cmp::max; | |
// This is meant to be an introductory problem to the technique. The question is, given | |
// a list of numbers and a number k, return the largest sum of k | |
// consecutive numbers in the list. | |
pub fn largest_continuous_sum(nums: Vec<isize>, k: usize) -> isize { | |
if nums.len() < k { | |
// undefined behavior |
This file contains 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
pub struct IntcodeVM { | |
memory: Vec<usize>, | |
ip: usize | |
} | |
impl IntcodeVM { | |
pub fn new(state: Vec<usize>) -> IntcodeVM { | |
IntcodeVM { memory: state, ip: 0 } | |
} |
This file contains 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::collections::{VecDeque, HashSet}; | |
use std::fmt::{self, Display, Formatter}; | |
use std::io; | |
use std::process::exit; | |
// This implementation is needlessly complicated, | |
// but it comes with a simple debugger which I find kinda neat. | |
// Just invoke vm.add_breakpoint(0) before vm.run() and use | |
// simple commands via stdin. |