Skip to content

Instantly share code, notes, and snippets.

View social-anthrax's full-sized avatar
🍎
Poking an iPhone

Artemis Livingstone social-anthrax

🍎
Poking an iPhone
View GitHub Profile
use std::usize;
use crate::task_handler::get_task;
fn most_common_bit(numbers: &Vec<usize>) -> usize {
let mut gamma: usize = 0;
for column in 0..12 {
let (one, zero): (Vec<usize>, Vec<usize>) = numbers
.iter()
.map(|x| (x >> column) & 1)
use crate::task_handler::get_task;
pub fn task2_1() -> String {
let input = get_task(2);
let mut depth = 0;
let mut horizontal = 0;
for line in input.lines() {
match line.split(' ').collect::<Vec<&str>>()[..] {
["forward", x] => horizontal = horizontal + x.parse::<i32>().unwrap(),
@social-anthrax
social-anthrax / AOC_day_1.rs
Last active December 1, 2021 15:30
solutions for day one of advent of code
use crate::task_handler::get_task;
pub fn task1_1() -> String {
let input: Vec<usize> = get_task(1)
.lines()
.map(|x| x.parse::<usize>().unwrap())
.collect();
input.windows(2).filter(|x| x[0] < x[1]).count().to_string()
}
pub fn task1_2() -> String {