Skip to content

Instantly share code, notes, and snippets.

View TheRealMichaelWang's full-sized avatar

Michael Wang TheRealMichaelWang

  • Atlanta, Georgia
  • 10:37 (UTC -05:00)
View GitHub Profile
@TheRealMichaelWang
TheRealMichaelWang / out.c
Created January 3, 2023 04:27
Buggy C Code
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct _nhp_array_char _nhp_array_char_t;
typedef struct _nhp_array__nhp_anonProcTypeNo0 _nhp_array__nhp_anonProcTypeNo0_t;
typedef struct _nhp_array__nhp_array_char _nhp_array__nhp_array_char_t;
typedef struct _nhp_enum_operand__ _nhp_enum_operand___t;
@TheRealMichaelWang
TheRealMichaelWang / fenwick.c
Created September 28, 2021 17:58
Fenwick/BIT Tree
#include <stdlib.h>
typedef struct fenwick_tree{
int* elems; //stores the elements of the input array
int *sums; //stores the "sum" of the array at a certain index
} fenwick_tree_t;
//Note sum because it's not a "hard" sum that stretches from index 0 to n, but rather from n's "parent" to n.
//inserts item and updates the sums accordingly
void fenwick_tree_insert(fenwick_tree_t* fenwick_tree, int elem, int i){
@TheRealMichaelWang
TheRealMichaelWang / conways.min
Created August 8, 2021 03:27
Conways Game of Life in Minima
include "random.min"
rem Instance of one game of conways game of life
record cell_batch {
matrix
epoch
rem initializes an instance with a specified number of cells and rows
proc init (rows, cols) {
set this.epoch to 0
@TheRealMichaelWang
TheRealMichaelWang / conways.txt
Created June 4, 2021 22:46
Conway's Game of Life, in FastCode
rem Conways Game of Life
rem Rules:
rem 1. Any live cell with fewer than two live neighbours dies, as if by underpopulation.
rem 2. Any live cell with two or three live neighbours lives on to the next generation.
rem 3. Any live cell with more than three live neighbours dies, as if by overpopulation.
rem 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
rem sets the console title
system("title Conways Game of Life!")