Skip to content

Instantly share code, notes, and snippets.

View simon-tiger's full-sized avatar

Simon Tiger simon-tiger

View GitHub Profile
### PROOF THAT YOU CANT PROVE EVERYTHING ###
# You can easily turn every statement into a program. If the program stops, or "halts", then the statement is true, and if it never stops, or "loops", the statement is false.
# Like, for example, the following program corresponds to the statement: "There's at least one even number that cannot be expressed as the sum of two primes" (this is the negation of the so-called "Goldbach Conjecture"):
def example(): # (assumes a get_primes function, but you get the idea)
n = 4
while True:
primes = get_primes(n)
found = False
'''
This is the code for level 2 of my series Sorting Algorithms.
More algorithms will come later.
The heapsort code comes from these resources:
https://brilliant.org/wiki/heap-sort/
http://www.zaxrosenberg.com/must-know-sorting-algorithms-in-python/
The rest I wrote myself.
'''
'''Shell Sort'''
class Stack:
def __init__(self):
self.data = []
def push(self, i):
self.data.append(i)
def peek(self):
return self.data[-1]
'''
This is the code for level 1 of my series Sorting Algorithms.
The Quicksort code I wrote myself. For the rest, I used these resources:
http://www.zaxrosenberg.com/must-know-sorting-algorithms-in-python/
https://brilliant.org/wiki/sorting-algorithms/
https://medium.com/@george.seif94/a-tour-of-the-top-5-sorting-algorithms-with-python-code-43ea9aa02889
'''
# Bubble Sort
def bubble_sort(L):
Polar:
- r = 1 - sin(t) (cardioid)
- r = (sin(t) sqrt(|cos(t)|)) / (sin(t) + 7/5) - 2 sin(t) + 2
Cartesian:
- (x^2 + y^2 - 1)^3 - x^2 y^3 = 0
- (y - 2(|x| + x^2 - 6) / 3(|x| + x^2 + 2))^2 + x^2 = 36
- x^2 + (y - cubert(x^2))^2 = 1
- glued curve
- x: -2 to 2
& (bitwise and)
| (bitwise or)
^ (bitwise xor)
~ (bitwise not)
<< (zero-fill bitshift left)
>> (signed bitshift right)
>>> (zero-fill bitshift right)
WEBGL // p5 WEBGL rendering mode.
createCanvas(w, h, renderer) // Creates a 3D canvas (if renderer is WEBGL).
// Primitives
plane(width, height) // Creates a plane in 3D space. Equivalent to rect() in the default rendering mode.
plane(width, height, detailX, detailY) // Creates a plane in 3D space with the number of triangle subdivisions specified.
box(width) // Creates a cube in 3D space.
box(width, height, depth) // Creates a cuboid in 3D space.
box(width, height, depth, detailX, detailY) // Creates a cuboid in 3D space with triangle subdivisions.
sphere(radius) // Creates a sphere in 3D space.
Array.prototype.choice = function() {
var i = floor(random(this.length));
return this[i];
}
var paragraphs = [];
function process(word) {
var text = textinput.value();
var words = splitTokens(text, ' .,:;!@#$%&*()\n');