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
import math | |
def kthPrime(k): | |
# k is non-negative | |
if k < 0: | |
return None | |
# an array to store primes | |
primes = [] | |
# use an array of booleans `isPrime` to indicate whether a number is a prime | |
# e.g. isPrime[2] is True means 2 is a prime | |
# upperLimit is the size of the array. We start from a small number |
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 lcs(x, y): | |
n = len(x) | |
m = len(y) | |
table = dict() # a hashtable, but we'll use it as a 2D array here | |
for i in range(n+1): # i=0,1,...,n | |
for j in range(m+1): # j=0,1,...,m | |
if i == 0 or j == 0: | |
table[i, j] = 0 | |
elif x[i-1] == y[j-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
p{ | |
width: 220px; | |
margin: 0; | |
} |
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
function loadOrFallback(scripts,idx) { | |
var successfully_loaded = false; | |
function testAndFallback() { | |
clearTimeout(fallback_timeout); | |
if (successfully_loaded) return; // already loaded successfully, so just bail | |
try { | |
scripts.tester(); | |
successfully_loaded = true; // won't execute if the previous "test" fails | |
scripts.success(); | |
// console.log("success: " + scripts.src[idx]); |
NewerOlder