Skip to content

Instantly share code, notes, and snippets.

@skeeto
skeeto / planet-puzzle.svg
Created August 20, 2016 17:34
Planet exploration puzzle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skeeto
skeeto / planet-explore.c
Created August 20, 2016 18:11
Planet exploration solver
/* 1) Immediately prints the base puzzle SVG to stdout.
* 2) Creates a path-*.svg each * time it hits a longest path.
* 3) Creates a solution-*.svg for each solution.
*/
#include <stdio.h>
#include <stdint.h>
#define WIDTH 8u
#define HEIGHT 8u
/* $ cc -std=c99 -Ofast -fopenmp -o julia julia.c -lm
* $ ./julia > output.ppm
* $ ppmtoy4m -F 60:1 < output.ppm > output.y4m
* $ x264 --qp 0 -o output.mp4 output.y4m
*
* Due to parallel compute, stdout must be seekable. Therefore it
* cannot be piped directly into ppmtoy4m.
*/
#define IMAGE_SIZE 600
#define IMAX 512
@skeeto
skeeto / Makefile
Last active February 28, 2017 23:47
16x16 "Pseudoku" generator
CC = c99
CFLAGS = -Wall -Wextra -O3 -g3
generate16: generate16.c
clean:
rm -f generate16
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#define A 10
#define B 30
#define C 5
#define N 1
#define RULE_B
@skeeto
skeeto / dice.c
Created June 24, 2017 19:13
Dice roll table
/* https://possiblywrong.wordpress.com/2017/06/24/dice-puzzle/ */
#include <stdio.h>
static void
fill_table(short *table, int n, long r)
{
if (n == 6)
table[r]++;
else
for (int i = 0; i < 6; i++)
@skeeto
skeeto / Makefile
Last active August 6, 2017 02:19
Arrow maze generator (/r/dailyprogrammer)
CC = cc -std=c89 -ansi
CFLAGS = -Wall -Wextra -O3 -march=native
maze: maze.c
clean:
rm -f maze
@skeeto
skeeto / blocks.c
Created August 15, 2017 20:15
​Challenge #326 [Hard] Multifaceted alphabet blocks
/* [2017-08-11] Challenge #326 [Hard] Multifaceted alphabet blocks
* https://redd.it/6t0zua
*/
#include <stdio.h>
#include <string.h>
#define N (1024ul * 1024ul)
static int
find(char blocks[][33], int n, unsigned long used, const char *word)
@skeeto
skeeto / Makefile
Created September 18, 2017 22:17
pi fractal
CC = c99
CFLAGS = -Wall -Wextra -Ofast
LDLIBS = -lm
pi: pi.c
@skeeto
skeeto / Makefile
Created September 19, 2017 18:04
Carpet Genetic Algorithm
CC = c99
CFLAGS = -Wall -Wextra -Ofast
all: genetic render
genetic: genetic.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ genetic.c $(LDLIBS)
render: render.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ render.c $(LDLIBS)