Skip to content

Instantly share code, notes, and snippets.

@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)
{
@weirddan455
weirddan455 / day3_part1.c
Created December 3, 2022 06:26
Advent of Code Day 3 Part 1
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static char get_priority(char c)
{
if (c >= 'a' && c <= 'z') {
@weirddan455
weirddan455 / day2.c
Created December 2, 2022 07:32
Advent of Code Day 2 Part 2
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
typedef enum ParseState
{
OPPONENT,
SPACE,
YOU,
NEWLINE