Skip to content

Instantly share code, notes, and snippets.

View AlphaSheep's full-sized avatar

Brendan Gray AlphaSheep

View GitHub Profile
@AlphaSheep
AlphaSheep / getHoverBoard.py
Created November 25, 2015 19:10
Downloads the images used by http://xkcd.com/1608/
#!/usr/bin/python3
'''
Downloads the images used by http://xkcd.com/1608/
Copyright (c) 2015 Brendan Gray
Copying and distribution of this file, with or without modification,
is permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.
@AlphaSheep
AlphaSheep / ContinentKinchRanks.py
Last active August 29, 2015 14:23
Goes through the WCA database, and calculates the KinchRanks for each person.
#! /usr/bin/python3
"""
Goes through the WCA database, and calculates the KinchRanks for each person.
Copyright (c) 2015 Brendan Gray
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.
#!/usr/bin/python3
'''
A graph generator for Rubik's cube times.
This code is a mess. It was never supposed to get this long. I'm sorry.
Copyright (c) 2015 Brendan Gray
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
@AlphaSheep
AlphaSheep / invert.py
Created June 3, 2015 09:56
Really Short Matrix Inverse
def invert(A):
''' Returns the inverse of A, where A is a square matrix in the form of a nested list of lists. '''
A = [A[i]+[int(i==j) for j in range(len(A))] for i in range(len(A))]
for i in range(len(A)):
A[i:] = sorted(A[i:], key=lambda r: -abs(r[i]))
A[i] = [A[i][j]/A[i][i] for j in range(len(A)*2)]
A = [[A[j][k] if i==j else A[j][k]-A[i][k]*A[j][i] for k in range(len(A)*2)] for j in range(len(A))]
return [A[i][-len(A):] for i in range(len(A))]