{{ 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:
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;
Created Aug 9, 2014
Cairo pentagonal grid
View cairo-pentagonal.ps
 %!PS-Adobe-2.0 %%Creator: Peter Taylor % Force A4 portrait. <> setpagedevice /hex { currentpoint 8 14 rlineto 6 0 rlineto 8 -14 rlineto
Last active Aug 29, 2015 — forked from Yaffle/URLUtils.js
View URLUtils.js
 /*jslint regexp: true, maxerr: 50, indent: 2 */ (function (global) { "use strict"; function URLUtils(url, baseURL) { var m = String(url).replace(/^\s+|\s+\$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@]*)(?::([^:@]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); if (!m) { throw new RangeError(); }
Last active Aug 29, 2015
Hunt the Wumpus; refactors of Dennis' code
View wumpus-a5.gs
 ## 0:DBGID; {['"#{\$stderr.puts Garray.new(\$stack).ginspect.to_s.slice(1..-2)#'DBGID):DBGID' }"']''*~;}:DEBUG; ## #[5:C,]{{.{[~@]}:>~.{-1%}:<~}%.&}8*({[.<><.<><]}:&~-{99rand}\$~5,{.<[.>.>]{&~}%.3{\$?~!!}:Q~"You smell a wumpus.\n"{*print}:,~.4Q"You feel a breeze.\n",'"#{'C):C';STDIN.gets()}"'++~~.10/3%@3%=\5%{&2Q"You killed the wumpus."{\<{>}3rand*\1"Your arrow didn't hit anything.\n",0}if}{\;.&3Q"You fell into the pit."*}if 1\$&3Q{;"You were killed by the wumpus."}*:n!}do]; #[5:C,]{{.{[~@]}:>~.{-1%}:<~}%.&}8*({[.<><.<><]}:&~-{99rand}\$~5,{.<[.>.>].{&3{\$?~!!}:Q~'You smell a wumpus.\n'{*print}:,~}/.{&4Q'You feel a breeze.\n',}/'"#{'C):C';STDIN.gets()}"'++~~.10/3%@=\5%{&2Q'You killed the wumpus.'{\<{>}3rand*\1"Your arrow didn't hit anything.\n",0}if}{\;.&3Q'You fell into the pit.'*}if 1\$&3Q{;'You were killed by the wumpus.'}*:n!}do]; #[5:C,]{{.{[~@]}:>~.{-1%}:<~}%.&}8*({[.<><.<><]}:&~-{99rand}\$~5,{.<[.>.>].{3{\$\&\?~!!}:Q~'You smell a wumpus.\n'{*print}:,~}/.{4Q'You feel a breeze.\n',}/'"#{'C):C';STDIN.gets()}"'++~~.
You can’t perform that action at this time.