{{ message }}

Instantly share code, notes, and snippets.

pjt33

Last active Apr 5, 2018
Gaussian ABC conjecture
View GaussianABC.cs
 using System; using System.Collections.Generic; using System.Linq; using System.Text; using BigInteger = System.Numerics.BigInteger; namespace Sandbox { // https://math.stackexchange.com/questions/2642142/complex-number-abc-conjecture // https://stackoverflow.com/questions/2269810/whats-a-nice-method-to-factor-gaussian-integers
Created Feb 23, 2018
Finding permutations with disjoint partial sums
View cs88476.py
 #!/usr/bin/python3 def flatten(index_map): flat = [0] * len(index_map) for key in index_map.keys(): flat[index_map[key]] = key return flat def emit_solution(x, partial_solution):
Last active Nov 23, 2017
A000329
View BigDecimalInterval.cs
 using System; using System.Collections.Generic; using System.Numerics; using System.Text; namespace Sandbox { public class Rational { public Rational(BigInteger num, BigInteger denom)
Last active Feb 26, 2017
Calculate OEIS A003122 with heavy memoisation
View A003122.py
 #!/usr/bin/python3 from functools import lru_cache class Partition: def __init__(self, maxPart, tail=None): self.part = maxPart self.tail = tail if tail is None:
Last active Dec 22, 2015
Enumerator for practical numbers
View PracticalNumbers.java
 package com.akshor.pjt33.math; import java.util.*; public class PracticalNumbers { public static void main(String[] args) { Generator gen = new Generator(); // Print all practical numbers up to 30000 for (int pr = gen.next(); pr <= 30000; pr = gen.next()) {
Last active Dec 19, 2015
Coursera video list: things to run in the console 1. Generate wiki markup for the subtitles page. 2. Generate a bash script to download the resources
View Build subtitles
 \$('a.lecture-link').each(function(){ var \$lectureLink = \$(this); var lectureId = \$lectureLink.data('lecture-id'); var title = \$lectureLink.text().trim().replace(/ *\([0-9]+:[0-9]+\)/, ''); console.log('* ' + title + ' [[Scigast:Subtitles:Lecture' + lectureId + ':en|English]] | [[Scigast:Subtitles:Lecture' + lectureId + ':es|Español]]'); }),null;
Last active Dec 19, 2015
PHP stacktrace in a loggable/echoable form.
View gist:5898943
 \$st = debug_backtrace(); \$lineNo = ''; \$stackTrace = ''; foreach (\$st as \$line) { if (isset(\$line['class'])) \$stackTrace .= \$line['class'].\$line['type'].\$line['function'].' at line '.\$lineNo . "\n"; else \$stackTrace .= \$line['function'].' in '.\$line['file'].' line '.\$lineNo . "\n"; \$lineNo = \$line['line']; }
Created Oct 21, 2015
View A263542.cs
 using System; using System.Collections.Generic; using System.Linq; namespace Sandbox { // NB This is not really "production-quality" code class Program { static void Main(string[] args) { for (int m = 2; m < 7; m++) { for (int n = 2; n <= m; n++) {
Created Oct 10, 2014
Count Quoridor wall positions
View QuoridorCounter.java
 import java.math.BigInteger; import java.util.*; public class QuoridorCounter { public static void main(String[] args) { List rows = new ArrayList(); char[] chs = new char[8]; for (int i = 0; i < 6561 /* 3^8 */; i++) { int r = i; for (int j = 0; j < 8; j++) {
Last active Aug 29, 2015
GenericLife
View AbstractLattice.java
 import java.awt.Point; import java.util.*; public abstract class AbstractLattice implements Tiling { // Use the idea of expansion and vertex mapping from my earlier aperiod tiling implementation. private Map> vertexNeighbourhood = new HashMap>(); private int scale = -1; // Geometry private final int dx0, dy0, dx1, dy1;