Skip to content

Instantly share code, notes, and snippets.

View thquinn's full-sized avatar

Tom Quinn thquinn

View GitHub Profile
@thquinn
thquinn / HilbertCalc.cs
Created August 1, 2023 07:55
In the limit Hilbert curve, what percentage of order 1 Hilbert curves that appear in it are "right side up"?
using System;
// In the limit Hilbert curve, what percentage of order 1 Hilbert curves that appear in it are "right side up"?
namespace HilbertCalc {
class Program {
static void Main(string[] args) {
ulong[] curves = new ulong[] { 1, 0, 0, 0 }; // index 0 is "right side up," each subsequent index is 90 degrees counterclockwise
for (int i = 1; i <= 20; i++) {
Console.WriteLine($"Order {i} Hilbert curve:");
ulong sum = curves[0] + curves[1] + curves[2] + curves[3];
@thquinn
thquinn / cantor_order_integers.py
Created August 4, 2023 02:29
List the positive integers in Cantor unpacking order of their prime factorizations.
from numpy import prod
# Can we reorder the positive integers based on a logical ordering of their prime factorizations?
# If we could iterate through all finite-sized tuples of nonnegative integers, we could increment
# the first element of each to uniquely cover all possible prime factorizations.
# We can extend and invert the Cantor pairing function to generate all k-tuples for any positive k,
# but now we're only iterating through the integers with highest prime factor p(k).
@thquinn
thquinn / sagemath_juggling.py
Last active June 2, 2024 07:24
A not-very-fast symbolic physics simulation using SymPy.
import os
import sage.all as sage
from itertools import combinations
from PIL import Image, ImageDraw
from typing import cast, Dict
from enum import Enum
os.system("clear")
class SimCircle: