Skip to content

Instantly share code, notes, and snippets.

@weirddan455
weirddan455 / main.rs
Created July 7, 2024 14:45
Advent of Code 2023 Day 14 Part 2
struct Grid {
width: usize,
height: usize,
data: Vec<u8>
}
fn get_grid() -> Grid {
let mut grid = Grid {
width: 0,
height: 0,
@weirddan455
weirddan455 / main.rs
Last active June 27, 2024 13:49
Advent of Code 2023 Day 5 Part 2
#[derive(Default)]
struct Map {
dst: u64,
src: u64,
range: u64
}
#[derive(Default)]
struct Seed {
start: u64,
@weirddan455
weirddan455 / part1.c
Created December 28, 2022 15:41
Advent of Code Day 24 Part 1
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#define BLIZZARD_LEFT 1
@weirddan455
weirddan455 / day25.c
Created December 28, 2022 00:12
Advent of Code Day 25
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
static long read_digit(char c)
{
switch (c) {
case '-':
return -1;
@weirddan455
weirddan455 / part2.c
Created December 19, 2022 09:45
Advent of Code Day 18 Part 2
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define EMPTY 0
#define LAVA 1
#define WATER 2
#define BOUNDS 3
@weirddan455
weirddan455 / part1.c
Created December 18, 2022 01:14
Advent of Code Day 16 Part 1
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#define MAX_NEIGHBORS 8
typedef struct Room
@weirddan455
weirddan455 / part2.c
Created December 15, 2022 10:55
Advent of Code Day 15 Part 2
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#define SCAN_BOUNDS 4000000
typedef struct Position
@weirddan455
weirddan455 / part1.c
Created December 14, 2022 03:35
Advent of Code Day 13 Part 1
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct Packet
{
int *data;
size_t size;
size_t capacity;
size_t num_lists;
@weirddan455
weirddan455 / visual.c
Created December 10, 2022 00:17
Advent of Code Day 9 Visualization
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#define TARGET_MS 20
#define SEGMENT_SIZE 3
static SDL_Renderer *init_sdl(void)
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
@weirddan455
weirddan455 / day3_part2.c
Created December 3, 2022 06:27
Advent of Code Day 3 Part 2
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static char get_priority(char c)
{