This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack: | |
def __init__(self): | |
self.data = [] | |
def push(self, i): | |
self.data.append(i) | |
def peek(self): | |
return self.data[-1] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
& (bitwise and) | |
| (bitwise or) | |
^ (bitwise xor) | |
~ (bitwise not) | |
<< (zero-fill bitshift left) | |
>> (signed bitshift right) | |
>>> (zero-fill bitshift right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
NewerOlder