Skip to content

Instantly share code, notes, and snippets.

@Gordin508
Gordin508 / main.rs
Last active January 29, 2024 02:25 — forked from icub3d/main.rs
Advent of Code 2019 - Day 05 // Intcode Computer
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.
@Gordin508
Gordin508 / main.rs
Last active January 25, 2024 03:54 — forked from icub3d/main.rs
Advent of Code 2019 - Day 02 // Intcode Computer
pub struct IntcodeVM {
memory: Vec<usize>,
ip: usize
}
impl IntcodeVM {
pub fn new(state: Vec<usize>) -> IntcodeVM {
IntcodeVM { memory: state, ip: 0 }
}
@Gordin508
Gordin508 / lib.rs
Last active January 13, 2024 08:37 — forked from icub3d/lib.rs
LeetCode #340 & #76
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