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::HashSet; | |
pub struct Solution; | |
impl Solution { | |
pub fn find_different_binary_string(nums: Vec<String>) -> String { | |
let n = nums.len(); | |
let nums = nums | |
.iter() | |
.map(|s| usize::from_str_radix(s, 2).unwrap()) |
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
[ | |
{ | |
// "ctrl+h": Focuses on the left editor group when the text editor is focused, Vim extension is active, and Vim is not in Insert mode. | |
"key": "ctrl+h", | |
"command": "workbench.action.focusLeftGroup", | |
"when": "editorTextFocus && vim.active && vim.mode != 'Insert'" | |
}, | |
{ | |
// "ctrl+l": Focuses on the right editor group when the text editor is focused, Vim extension is active, and Vim is not in Insert mode. | |
"key": "ctrl+l", |
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
fn height(input: &str) -> Vec<isize> { | |
input | |
.lines() | |
.flat_map(|line| line.chars().enumerate()) | |
.filter(|(_, c)| *c == '#') | |
.fold(vec![-1; 5], |mut heights, (i, _)| { | |
heights[i] += 1; | |
heights | |
}) | |
} |
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::{HashMap, HashSet, VecDeque}; | |
use std::fmt::Display; | |
use std::io::Write; | |
use nom::{ | |
branch::alt, bytes::complete::tag, character::complete::alphanumeric1, combinator::map, | |
multi::separated_list1, sequence::tuple, IResult, | |
}; | |
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] |
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::{HashMap, HashSet, VecDeque}; | |
use itertools::Itertools; | |
fn main() { | |
let now = std::time::Instant::now(); | |
let input = include_str!("input.txt"); | |
// Parse the input into a graph keeping track of vertices and edges. | |
let (vertices, edges) = input.lines().fold( |
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::HashMap, iter::once}; | |
use rayon::prelude::*; | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let input = include_str!("input.txt"); | |
// Find the 2000th secret for each value and sum them up. | |
let now = std::time::Instant::now(); | |
let p1 = input |
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::{HashMap, HashSet, VecDeque}, | |
sync::OnceLock, | |
}; | |
use cached::proc_macro::cached; | |
use itertools::Itertools; | |
// The next two functions basically find all the possible shortest paths between | |
// any two points on each of the keypads. Because the combinations are small, we |
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::HashSet; | |
use pathfinding::directed::dijkstra::dijkstra; | |
use rayon::prelude::*; | |
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | |
struct Point { | |
x: isize, | |
y: isize, | |
} |
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::HashMap; | |
const INPUT: &'static str = include_str!("input.txt"); | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
// This was a fairly simply input, so I just split_once on the double | |
// newline and then split the patterns by comma and the problems by newline. | |
let (patterns, problems) = INPUT | |
.split_once("\r\n\r\n") | |
.ok_or("Failed to split input")?; |
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::{BinaryHeap, HashMap, HashSet}; | |
use std::hash::Hash; | |
use nom::{ | |
bytes::complete::tag, character::complete::digit1, combinator::map_res, multi::separated_list1, | |
sequence::separated_pair, IResult, | |
}; | |
use rayon::iter::{IntoParallelIterator, ParallelIterator}; | |
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] |
NewerOlder