Skip to content

Instantly share code, notes, and snippets.

View Plutor's full-sized avatar
🗯️

Logan Ingalls Plutor

🗯️
View GitHub Profile
distance_cache = {}
gcd_cache = {}
def DelacorteInit():
# TODO: This half of the initialization could be done faster.
for row1 in range(28):
for col1 in range(28):
for row2 in range(28):
row_distance = (row1 - row2) ** 2
for col2 in range(28):
distance_cache[row1, col1, row2, col2] = (
@Plutor
Plutor / gist:16a490f2f79e29263a9b
Last active August 29, 2015 14:01
What Bill Belichick has done with the Patriots' first round draft picks
Data from http://www.prosportstransactions.com/football/DraftTrades/Years/
2000 (#16): Sent to Jets as compensation for his own hiring
2001 (#6): Drafted Richard Seymour
2002 (#32): Traded up to #21, drafted Dan Graham
2003 (#14): Acquired via trade for Drew Bledsoe, traded up to #13, drafted Ty Warren
2003 (#19): Traded down to 2nd round plus 2004 1st round
2004 (#21): Acquired via above trade, drafted Vince Wilfork
2004 (#32): Drafted Ben Watson
2005 (#32): Drafted Logan Mankins
@Plutor
Plutor / penalty-list-2013-avg-yards.txt
Created May 7, 2014 14:41
Most called penalties, most total yards, and most average yards in the 2013 season
16.2 Defensive Pass Interference
15.0 Roughing the Kicker
15.0 Interference with Opportunity to Catch
15.0 Illegal Peelback
15.0 Illegal Cut
15.0 Fair Catch Interference
15.0 Face Mask
15.0 Disqualification
15.0 Clipping
14.2 Personal Foul
@Plutor
Plutor / perfectinnings.awk
Last active August 29, 2015 14:00
How far does the normal baseball game get while being perfect
# Run against *.EV? in a file from <http://www.retrosheet.org/game.htm>
BEGIN {
FS=","
}
$1 == "id" {
if (awayisperfect) { print "perfect" }
if (homeisperfect) { print "perfect" }
awayisperfect = 1
@Plutor
Plutor / gist:9071314
Last active August 29, 2015 13:56
Tracing Aragorn's bloodline to Elros half-elven (actually five-eigths)
  • Aragorn
  • [... 15 previous Chieftains of the Dúnedain ...]
  • Arvedui, last King of Arthedain
  • [... 14 previous Kings of Arthedain ...]
  • Eärendur, last King of Arnor
  • [... 7 previous Kings of Arnor ...]
  • Isildur, King of Arnor
  • Elendil, King of Arnor and last Lord of Andúnië
  • Amandil
  • [... 16 previous Lords of Andúnië ...]
@Plutor
Plutor / get_superbowl_comments.py
Created February 3, 2014 19:27
Get reddit Super Bowl threads comment list
import json
import re
import urllib
import urllib2
from time import sleep
comments = 0
missing = []
csv = open('super-bowl-comments.csv', 'w')
@Plutor
Plutor / Output
Created December 4, 2013 16:23 — forked from anonymous/Output
If your descendants alternated marrying someone completely of $ethnicity and someone not, they would approach 1/3 and 2/3 of that ethnicity. Re: <http://www.reddit.com/r/learnmath/comments/1s0vyx/what_is_the_fewest_number_of_generations_that_it/>
Generation 0: Parents 0.000% and 0% ethnic had a child 0.000% ethnic
Generation 1: Parents 0.000% and 100% ethnic had a child 50.000% ethnic
Generation 2: Parents 50.000% and 0% ethnic had a child 25.000% ethnic
Generation 3: Parents 25.000% and 100% ethnic had a child 62.500% ethnic
Generation 4: Parents 62.500% and 0% ethnic had a child 31.250% ethnic
Generation 5: Parents 31.250% and 100% ethnic had a child 65.625% ethnic
Generation 6: Parents 65.625% and 0% ethnic had a child 32.812% ethnic
Generation 7: Parents 32.812% and 100% ethnic had a child 66.406% ethnic
Generation 8: Parents 66.406% and 0% ethnic had a child 33.203% ethnic
Generation 9: Parents 33.203% and 100% ethnic had a child 66.602% ethnic
@Plutor
Plutor / floating_point_ones.cc
Created August 13, 2013 14:29
A demonstration of the inaccuracy of storing large numbers in floating point.
#include <stdio.h>
int main() {
printf("1111111111111111 = %.0f\n", 1111111111111111.0);
printf("11111111111111111 = %.0f\n", 11111111111111111.0);
printf("111111111111111111 = %.0f\n", 111111111111111111.0);
printf("1111111111111111111 = %.0f\n", 1111111111111111111.0);
printf("11111111111111111111 = %.0f\n", 11111111111111111111.0);
printf("111111111111111111111 = %.0f\n", 111111111111111111111.0);
return 0;
@Plutor
Plutor / American League
Last active December 18, 2015 02:08
All-WAR Game Roster - The All-Star Game roster if it was determined by WAR instead of voting
Current ballot counts: <http://mlb.mlb.com/news/article.jsp?ymd=20130603&content_id=49475890>
Current batting WAR: <http://www.baseball-reference.com/leagues/AL/2013-value-batting.shtml#players_value_batting::15>
Current pitching WAR: <http://www.baseball-reference.com/leagues/AL/2013-value-pitching.shtml#players_value_pitching::18>
POS NAME CURRENT PLACE IN VOTING
1B: Chris Davis 1
2B: Dustin Pedroia 3
SS: Jhonny Peralta 3
3B: Manny Machado 2
OF: Coco Crisp 13
@Plutor
Plutor / pinary.py
Last active October 21, 2020 10:56
Decimal to pinary conversion
"""Convert decimal numbers to pinary (base pi).
Fractional and even irrational bases are possible, but aren't really useful for
anything. Base pi has four digits: 0, 1, 2, and 3. What's interesting is that
there's some "space" between the highest digit and the base, which means that
there are numbers with multiple valid representations. You'll notice:
decimal 7.000000 = pinary 20.2021120021
decimal 8.000000 = pinary 21.2021120021
decimal 9.000000 = pinary 22.2021120021