Skip to content

Instantly share code, notes, and snippets.

@olligobber
olligobber / mags.py
Last active October 26, 2017 09:22
Person A can staple 100 magazines in 5 minutes and fold 100 letters in 10 minutes. Person B can staple 100 magazines in 10 minutes and fold 100 letters in 5 minutes. Person C can staple 100 magazines in 8 minutes and fold 100 letters in 6 minutes. If they work together, how long will it take for them to staple 100 magazines and fold 100 letters?
total=100
def A(m,l):
return 5*m + 10*l
def B(m,l):
return 10*m + 5*l
def C(m,l):
return 8*m + 6*l
@olligobber
olligobber / Tupper.py
Last active February 13, 2017 13:06
An incorrect implementation to render for Tupper's Self Referential Formula. https://en.wikipedia.org/wiki/Tupper's_self-referential_formula
inp = int(input("k = "))
inp = inp//7
out = []
chars = ["░", "█"]
for i in range(17):
out.append("")
for i in range(106):
for j in range(17):
out[j]+=chars[inp&1]
inp = inp>>1
@olligobber
olligobber / typable.txt
Created August 28, 2016 05:22
The longest words that count as words as you type them.
9 ['ballonets', 'balloters', 'champerty', 'collarets', 'composers', 'machinery', 'minimised', 'minimiser', 'minimises', 'patentees', 'patenters', 'photomaps', 'quarterns', 'reversers', 'reversist', 'sheathers', 'sheathery']
@olligobber
olligobber / base_pi.py
Last active July 3, 2017 13:42
Converts a number to base pi, demonstrating its uselessness for most numbers, example usage at top of file.
#!/usr/bin/env python3
"""
Command line use:
$ python3 base_pi.py -3 -1 0 2 3.141592653589793238462643383279502 -9.8696044010893586188344909998761511353136 4 0.5 0.333333333333333333333
-3
-1
0
2
@olligobber
olligobber / loadMore.js
Last active April 25, 2018 23:25
Loads the entire Watch Later list on YouTube (https://www.youtube.com/playlist?list=WL&disable_polymer=true)
loadMore = function($) { if ($(".yt-uix-load-more")) { $(".yt-uix-load-more").click(); setTimeout(loadMore, 2000, $); } }; loadMore($);
@olligobber
olligobber / music.nb
Created October 25, 2017 09:57
Demonstration of basic chiptune waves in Mathematica
ToPitch[x_] := 440 2^((x - 9)/12)
Song[t_] := Piecewise[{{ToPitch[2], 0 <= t <= 2.5},{ToPitch[5], 3 <= t <= 5.5},{ToPitch[2], 6 <= t <= 7.5},{ToPitch[2], 8 <= t <= 8.5},{ToPitch[5], 9 <= t <= 10.5},{ToPitch[7], 11 <= t <= 11.5},{ToPitch[9], 12 <= t <= 13.5},{ToPitch[12], 14 <= t <= 14.5},{ToPitch[9], 15 <= t <= 16.5},{ToPitch[5], 17 <= t <= 17.5},{ToPitch[2], 18 <= t <= 19.5},{ToPitch[0], 20 <= t <= 20.5},{ToPitch[2], 21 <= t <= 22.5},{ToPitch[2], 24 <= t <= 31.5}}, 0]
Play[SquareWave[Song[6 t] t], {t, -0.1, 5.5}]
Play[2 SawtoothWave[Song[6 t] t] - 1, {t, -0.1, 5.5}]
Play[TriangleWave[Song[6 t] t], {t, -0.1, 5.5}]
Play[Sin[Song[6 t] t 2 Pi], {t, -0.1, 5.5}]
@olligobber
olligobber / main.cpp
Last active November 15, 2017 03:56
Solves something
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
class solution {
public:
int structure[8][8];
bool operator== (solution other) {
@olligobber
olligobber / Proof By Contradiction.txt
Created December 29, 2017 06:36
A proof of "Proof by Contradiction" using propositional calculus as presented by Douglas R. Hofstader in "An Eternal Golden Braid"
[
(P->(Q&~Q)) Premise
[
P Premise
(P->(Q&~Q)) Carry-Over
(Q&~Q) Detachment
Q Separation
~Q Separation
[
P Premise
@olligobber
olligobber / littlefibs.hs
Created January 24, 2018 06:58
Determines which set of 5 cards can be used such that the sum of every size 2 and size 3 subset is unique
type Subset = [Int]
-- choose n xs is a list of all ways of choosing n things from xs
choose :: Int -> [a] -> [[a]]
choose 0 _ = [[]] -- one way to choose nothing
choose _ [] = [] -- no way to choose non-zero number of things from nothing
choose n (x:xs)
| n < 0 = undefined -- no way to choose negative number of things
| otherwise = with ++ without where
with = (x:) <$> choose (n-1) xs -- choices including x
#! /usr/bin/env python3
identity = lambda x: x
b_true = lambda x: lambda y: x
b_false = lambda x: lambda y: y
b_not = lambda b: b(b_false)(b_true)
b_and = lambda x: lambda y: x(y)(x)
b_or = lambda x: lambda y: x(x)(y)
b_xor = lambda x: lambda y: x(b_not(y))(y)