Skip to content

Instantly share code, notes, and snippets.

View typester's full-sized avatar
😇

Daisuke Murase typester

😇
View GitHub Profile
@typester
typester / main.rs
Created December 12, 2023 05:11
2023 Advent of Code Day 9
const INPUT: &str = "..snip..";
fn main() {
let sum: i64 = INPUT.lines()
.map(extract_digits)
.map(|d| extrapolate_next(&d))
.sum();
println!("part1: {}", sum);
let sum: i64 = INPUT.lines()
@typester
typester / main.rs
Created December 10, 2023 17:00
2023 Advent of Code Day 8
use std::collections::HashMap;
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = "..snip..";
fn main() {
let mut iter = INPUT.lines();
@typester
typester / main.rs
Created December 9, 2023 17:33
2023 Advent of Code Day 7
use std::{collections::{HashMap, BinaryHeap}, cmp::Reverse};
const INPUT: &str = "..snip..";
fn main() {
let mut heap: BinaryHeap<Reverse<Cards>> = INPUT.lines()
.map(parse)
.fold(BinaryHeap::new(), |mut acc, cards| {
acc.push(Reverse(cards));
acc
@typester
typester / main.rs
Created December 6, 2023 15:48
2023 Advent of Code Day 6
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = "..snip..";
fn main() {
let races = parse_input(INPUT);
let mut res: usize = 0;
for race in races.iter() {
let count =
@typester
typester / main.rs
Created December 5, 2023 16:20
2023 Advent of Code Day 5
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = "..snip..";
lazy_static! {
static ref RE_NUM: Regex = Regex::new(r"(\d+)").unwrap();
}
#[derive(Debug)]
@typester
typester / main.rs
Created December 5, 2023 13:45
2023 Advent of Code Day 4
use std::collections::HashMap;
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = "..snip..";
fn main() {
let sum: u32 = INPUT.lines()
.map(parse_game)
@typester
typester / main.rs
Created December 3, 2023 14:02
2023 Advent of Code Day 3
use std::collections::HashMap;
const INPUT: &str = "..snip..";
#[derive(Debug)]
struct Info {
symbol_map: Vec<Vec<bool>>,
numbers: Vec<Number>,
}
@typester
typester / main.rs
Created December 3, 2023 14:01
2023 Advent of Code Day 2
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = "..snip..";
fn main() {
let sum: u32 = INPUT.lines()
.map(parse_game_info)
.filter(check_cube_count)
.map(|game| game.id)
@typester
typester / main.rs
Created December 3, 2023 13:59
2023 Advent of Code Day 1
const INPUT: &str = "...snip...";
fn main() {
// part1
let sum: u32 = INPUT.lines()
.map(extract_digit)
.sum();
println!("part1 sum: {}", sum);
// part2
@typester
typester / hhkb.sh
Created October 14, 2019 18:21
my hhkb settings
#!/bin/sh
set -e
# reset
pkill xcape | echo -n
setxkbmap -layout us
# SandS
xmodmap -e 'keycode 255=space'