Skip to content

Instantly share code, notes, and snippets.

View laserbat's full-sized avatar

Olga Ustiuzhanina laserbat

View GitHub Profile
@laserbat
laserbat / lc0.config
Created November 19, 2022 13:54
Maia chess config
threads=1
task-workers=0
out-of-order-eval=false
max-prefetch=0
minibatch-size=1
nncache=0
smart-pruning-factor=0
#include <complex.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>
#define SR 44100
#define SIMPLE_HARMONIC
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define W (1080 / 2)
#define H (1920 / 2)
#define MAX_HEADER 128
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __SIZEOF_INT128__
typedef __uint128_t block_t;
#else
#warning "128-bit integers not supported, using 64-bit blocks!"
typedef uint64_t block_t;
#endif
#!/usr/bin/python3
from collections import defaultdict
with open("input.txt", "r", encoding="utf8") as file:
data = [[int(char) for char in line.strip()] for line in file.readlines()]
S = 5
W, H = len(data), len(data[0])
@laserbat
laserbat / day_1.sed
Last active December 14, 2021 20:17
2021 AOC in sed
#!/bin/sed -Enf
# Note: this code is intended for GNU sed, other implementations of sed might have issues running it.
#
# Usage:
# $ ./day_1.sed < ./input.txt
G
s/\n/;/m
h
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define W 1920
#define H 1080
const double start_x = 0.1;
const double start_y = 0;
// Compile with:
// $ gcc -Ofast -march=native -fopenmp ./CA.c -o CA
// Output is stream of PPM frames that can be played with mpv:
// $ ./CA | mpv - --scale=nearest
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
@laserbat
laserbat / ks.c
Last active September 22, 2021 09:36
Finite-difference code for 2D Kuramoto-Sivashinsky equation
// Finite-difference code for 2D Kuramoto-Sivashinsky equation.
//
// Uses isotropic stencils for spatial discretization and
// RK4 for time stepping.
//
// Should have O(h^4) error in time and space.
//
// Compile with:
// $ gcc -Ofast -march=native -fopenmp ./ks.c -o ks -lm
// View the simulation using mpv:
@laserbat
laserbat / cahn_hilliard.c
Last active March 22, 2021 17:24
Simple simulation of Cahn Hilliard equation
// Compile with:
// $ gcc -Ofast -march=native -fopenmp ./cahn_hilliard.c -o cahn_hilliard -lm
// View the simulation using mpv:
// $ ./cahn_hilliard | mpv - --scale=ewa_lanczossoft --fs
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>