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::Read; | |
| #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd)] | |
| struct Matrix<T> { | |
| rows: usize, | |
| columns: usize, | |
| buf: Vec<T>, | |
| } | |
| #[derive(Clone, Debug, PartialEq, Eq)] |
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::collections::BTreeMap; | |
| use std::io::Read; | |
| fn contains_n_of_any_letter(id: &str, n: i64) -> bool { | |
| let mut frequency_count = BTreeMap::new(); | |
| for c in id.chars() { | |
| *frequency_count.entry(c).or_insert(0) += 1; | |
| } |
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::Read; | |
| fn common_str(id1: &str, id2: &str) -> String { | |
| let mut common= String::new(); | |
| for (char1, char2) in id1.chars().zip(id2.chars()) { | |
| if char1 == char2 { | |
| common.push(char1); | |
| } | |
| } |
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
| extern crate regex; | |
| #[macro_use] extern crate lazy_static; | |
| use std::io::Read; | |
| use std::collections::BTreeMap; | |
| use regex::Regex; | |
| #[derive(Debug)] | |
| struct GuardProfile { | |
| id: usize, // The guard id |
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; | |
| fn characters_match(a: char, b: char) -> bool { | |
| return a.to_ascii_lowercase() == b.to_ascii_lowercase() && | |
| (a.is_ascii_lowercase() && b.is_ascii_uppercase() || a.is_ascii_uppercase() && b.is_ascii_lowercase()) | |
| } | |
| fn process_polymer_reaction_step(polymer: &mut String) -> usize { | |
| let mut num_changes = 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
| use std::str::FromStr; | |
| use std::num::ParseIntError; | |
| use std::io::Read; | |
| #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd)] | |
| struct Matrix<T> { | |
| rows: usize, | |
| columns: usize, | |
| buf: Vec<T>, | |
| } |
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
| #[derive(Debug)] | |
| pub struct Tree { | |
| children: Vec<Tree>, | |
| metadata: Vec<i64>, | |
| } | |
| impl Tree { | |
| fn new() -> Tree { | |
| Tree { | |
| children: Vec::new(), |
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::collections::VecDeque; | |
| #[derive(Debug)] | |
| struct ParseInputError {} | |
| /// Parses a line of input to give (number of players, largest marble used) | |
| fn parse_input(input: &str) -> Result<(usize, usize), ParseInputError> { | |
| let numbers: Vec<_> = input | |
| .trim() | |
| .split_whitespace() |
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
| #[macro_use] extern crate scan_fmt; | |
| use std::io::BufRead; | |
| #[derive(Debug)] | |
| struct Star { | |
| position: (i64, i64), | |
| velocity: (i64, 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 rayon::prelude::*; | |
| const GRID_SIZE: usize = 300; | |
| fn find_hundreds_digit(value: i64) -> i64 { | |
| (value / 100) % 10 | |
| } | |
| fn find_grid_cell_value(x: usize, y: usize, serial: i64) -> i64 { | |
| // internals use (0, 0) as origin |
OlderNewer