Skip to content

Instantly share code, notes, and snippets.

@XerxesZorgon
XerxesZorgon / Kelly.py
Created October 10, 2020 17:19
Kelly return ratio plot and Monte Carlo simulation
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 21 14:56:39 2020
Kelly Criterion functions
@author: johnx
"""
import numpy as np
@XerxesZorgon
XerxesZorgon / BezierHull.m
Last active July 2, 2021 15:31
Octave functions for generating Bezier yacht hull curves using Letcher's method
% Generate yacht hull lines using Letcher's method with all curves defined
% analytically using Bezier curves
%
%
%
% Input(s)
% fName: Name of Excel file containing Bezier points
%
% Output(s)
% BezStruct:
@XerxesZorgon
XerxesZorgon / curveString.m
Created October 20, 2020 18:16
Generates string for Bezier curves in GeoGebra
% Generates Bezier polynomials in x and y for use in Geogebra
%
%
% Input(s)
% n: Degree of Bezier curve
%
% Output(s)
% cStr: String used to define Bezier curve in Geogebra
%
% Example:
@XerxesZorgon
XerxesZorgon / Turtles Circling Sun and Moon.nlogo
Created November 18, 2020 19:32
NetLogo demonstration of circling turtles
@XerxesZorgon
XerxesZorgon / sumPart.gp
Last active January 1, 2026 20:21
Additive partitions in PARI/GP
/*
Additive partitions of integers
Inputs:
t: Integer (Target number)
c: Number of elements in the sum (Size of the cage)
u: Solutions must contain unique entries if set (Set u=0 if cage spans multiple rows or columns)
e: Exclusion set (numbers will not appear in output list)
n: Maximum integer in the sum partition (Size of the KenKen puzzle, default = 9)
@XerxesZorgon
XerxesZorgon / kFilt.gp
Created December 30, 2020 22:12
Filtering function for KenKen in PARI/GP
/*
Filters vectors for KenKen game
Inputs
v: vector
c: Number of elements in the sum (size of the KenKen cell)
n: Maximum value in the sum (length of a side in the game)
u: T/F flag for uniqueness. Set if the cell is contained in a single row or column
e: Exclusion set vector. Numbers appearing in the same row or column as the cell
@XerxesZorgon
XerxesZorgon / unique.gp
Created December 30, 2020 22:16
PARI/GP function returns unique elements of a vector, tests vectors for uniqueness
/*
Returns a vector of the unique elements of v
Input
v: vector
Output
u: Vector of unique elements of v
Example:
@XerxesZorgon
XerxesZorgon / mnumbpart.gp
Created December 30, 2020 22:19
Returns the cardinality of the multiplicative partition set for an integer (in PARI/GP)
/*
Returns the number of multiplicative partitions of integer n
Ref: https://oeis.org/A001055
https://oeis.org/A162247
https://oeis.org/A162247/a162247.txt
Inputs:
n: Non-negative integer
m: Maximum factor (optional)
@XerxesZorgon
XerxesZorgon / mpartitions.gp
Created December 30, 2020 22:21
PARI/GP function to generate the set of multiplicative partitions of a non-negative integer
/*
Returns the multiplicative partition of integer n
Ref: https://oeis.org/A001055
https://oeis.org/A162247
https://oeis.org/A162247/a162247.txt
Inputs:
n: Non-negative integer
Output:
@XerxesZorgon
XerxesZorgon / multPart.gp
Last active January 1, 2026 20:23
Multiplicative partition helper function for KenKen puzzles in PARI/GP
/*
Multiplicative partitions of integers
Inputs:
t: Integer (Target number)
c: Number of elements in the sum (Size of the cage)
u: Solutions must contain unique entries if set (Set u=0 if cage spans multiple rows or columns)
e: Exclusion set (numbers will not appear in output list)
n: Maximum integer in the sum partition (Size of the KenKen puzzle, default = 9)