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
#!/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. |
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
#! /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. |
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
#!/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, |
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
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))] |
NewerOlder