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
//! # TrieMap, A Trie-based Map for Rust | |
//! | |
//! Like a HashMap, values are stored and accessible by keys. Lookups can be | |
//! much faster than a HashMap, but there are some limitations on what can be | |
//! used for a key, and the memory is potentially higher, but not always. | |
//! | |
//! The keys are u8 bytes and the base value and range can be specified. The | |
//! greater the range, the more memory is used per node. The base value is used | |
//! to adjust the byte values of the keys to serve as indices into the internal | |
//! arrays within nodes that hold handles to descendant nodes. The base value |
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::mem::swap; | |
const ASCII_START: usize = b' ' as usize; | |
const ASCII_END : usize = b'~' as usize; | |
fn ascii_count_sort(arr: &mut Vec<String>, place: usize) { | |
let size = arr.len(); | |
let mut output = vec![String::default(); size]; | |
let mut count = [0; ASCII_END - ASCII_START + 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
//! Advent of Code 2023 Day 25 - Snowverload | |
//! | |
//! Part 1: Find the three wires you need to disconnect in order to divide the | |
//! components into two separate groups. What do you get if you multiply | |
//! the sizes of these two groups together? | |
use std::collections::{HashMap, HashSet}; | |
use std::error::Error; | |
use std::fs::File; | |
use std::io::{BufRead, BufReader}; |
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
//! Advent of Code 2023 Day 20 - Pulse Propagation | |
//! | |
//! Part 1: Consult your module configuration; determine the number of low | |
//! pulses and high pulses that would be sent after pushing the button | |
//! 1000 times, waiting for all pulses to be fully handled after each | |
//! push of the button. What do you get if you multiply the total number | |
//! of low pulses sent by the total number of high pulses sent? | |
//! Part 2: Reset all modules to their default states. Waiting for all pulses | |
//! to be fully handled after each button press, what is the fewest | |
//! number of button presses required to deliver a single low pulse to |
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
//! Brent's Algorithm - Online Version. An instance of `BrentOnline` can be used | |
//! to find the length of a cycle in a sequence and the start index of the | |
//! cycle. | |
//! | |
//! The object does store a portion of the series internally. So in most cases | |
//! this module will be suitable; however, if series are analyzed that have | |
//! very large cycles, some significant memory could be used depending on the | |
//! value type. Once a cycle is found it immediately drops its stored memory and | |
//! returns the cycle information. | |
//! |
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
//! Advent of Code 2023 Day 18 - Lavaduct Lagoon | |
//! | |
//! Part 1: The Elves are concerned the lagoon won't be large enough; if they | |
//! follow their dig plan, how many cubic meters of lava could it hold? | |
//! Part 2: Convert the hexadecimal color codes into the correct instructions; | |
//! if the Elves follow this new dig plan, how many cubic meters of lava | |
//! could the lagoon hold? | |
use std::collections::{HashSet, BTreeSet}; | |
use std::error::Error; |
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
//! Advent of Code 2023 Day 17 - Clumsy Crucible | |
//! | |
//! Part 1: Direct the crucible from the lava pool to the machine parts factory | |
//! with the least heat loss. | |
//! Part 2: Direct the larger crucible from the lava pool to the machine parts | |
//! factory with the least heat loss. | |
use std::cmp::Reverse; | |
use std::collections::{BinaryHeap, HashMap, HashSet}; | |
use std::error::Error; |
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
//! Advent of Code 2023 Day 7 - Camel Cards | |
//! | |
//! Part 1: Evaluate and sort the hands, then calculate the winnings. | |
//! Part 2: Evaluate the hands with Jokers wild, then calculate the winnings. | |
use std::fs::File; | |
use std::error::Error; | |
use std::io::{BufRead, BufReader}; | |
use std::time::Instant; |
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
//! Advent of Code 2023 Day 6 - Wait For It | |
//! | |
//! part 1: Calculate the product of the number of t_hold times that win each of | |
//! the races. | |
//! Part 2: Given one race with large parameters, calculate the number of t_hold | |
//! times that win. | |
use std::fs::read_to_string; | |
use std::error::Error; | |
use std::time::Instant; |
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
//! Advent of Code 2023 Day 5 - If You Give A Seed Fertilizer | |
//! | |
//! part 1: Find the lowest location corresponding to each seed. | |
//! Part 2: Find the lowest location corresponding to each seed range. | |
use std::fs::File; | |
use std::error::Error; | |
use std::io::{BufRead, BufReader}; | |
use regex::Regex; |
NewerOlder