This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int FirstPrimeFactor(int n) | |
{ | |
if(n == 0 || n == 1) | |
{ | |
return n; // 0 and 1 have no prime factors | |
} | |
if(n < 0) | |
{ | |
n = -n; // Work with absolute value | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Online C compiler to run C program online | |
#include <stdio.h> | |
int FindCubeInPrimeFactorization(int n) | |
{ | |
if (n == 0) return 0; // 0³ = 0 | |
if (n == 1) return 1; // 1³ = 1 | |
int cube = 1; | |
for(int p = 2; p * p <= n; p++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Full derivation here: https://leetarxiv.substack.com/p/conic-sections-matrix-theory | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
typedef struct{ double x, y; }Point; | |
//Run: clear && gcc ConicPlot.c -lm -o m.o && ./m.o | |
// Solve conic equation for y given x | |
bool GetConicPoints(double A, double B, double C, double F, double G, double H, double x, Point* y1, Point* y2) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code Explained : https://leetarxiv.substack.com/p/conic-sections-matrix-theory | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <assert.h> | |
#define COMPARE_EPSILON 1e-6f | |
#define INDEX(x, y, cols) ((x) * (cols) + (y)) | |
typedef enum matrix_type_enum MatrixType; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __EMSCRIPTEN__ | |
#include <emscripten.h> | |
#include <SDL.h> | |
#include <SDL_opengles2.h> | |
#else | |
#include <SLD2/SDL.h> | |
#include <SDL2/SDL_opengles2.h> | |
#endif | |
#ifndef M_PI | |
#define M_PI 3.14159265358979323846 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __EMSCRIPTEN__ | |
#include <emscripten.h> | |
#include <SDL.h> | |
#include <SDL_opengles2.h> | |
#else | |
#include <SLD2/SDL.h> | |
#include <SDL2/SDL_opengles2.h> | |
#endif | |
#ifndef M_PI | |
#define M_PI 3.14159265358979323846 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Written guide to this code available here: https://leetarxiv.substack.com/p/parsing-safetensors-file-format | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <math.h> | |
#include <sys/mman.h> | |
#include <stdbool.h> | |
#include "Dependencies/cJSON.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Full description: https://leetarxiv.substack.com/p/an-efficient-anti-aliasing-technique | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <math.h> | |
#define STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" | |
typedef struct point_struct Point; | |
typedef uint32_t RGBA; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <math.h> | |
#define STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" | |
typedef struct point_struct Point; | |
typedef uint32_t RGBA; | |
struct point_struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <stdint.h> | |
#include <gmp.h> | |
#include <assert.h> | |
#define STB_DS_IMPLEMENTATION | |
#include "stb_ds.h" | |
//clear && gcc Nichols.c -lm -lgmp -o m.o && ./m.o |
NewerOlder