View gist:1086093
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
seq = [1,2,3] | |
n=len(seq) | |
for i in range(n): | |
for j in range(n): | |
print "%s * %s = %s"%(seq[i],seq[j],seq[i]*seq[j]) |
View gist:1086097
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
seq = [1,2,3] | |
n=len(seq) | |
for i in range(n): | |
for j in range(i,n): | |
print "%s * %s = %s"%(seq[i],seq[j],seq[i]*seq[j]) |
View gist:1086105
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
seq = [1,2,3] | |
n=len(seq) | |
for i in range(n): | |
for j in range(i+1,n): | |
print "%s * %s = %s"%(seq[i],seq[j],seq[i]*seq[j]) |
View gist:1086107
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
seq = [1,2,3] | |
n=len(seq) | |
for i in range(n-1): | |
for j in range(i+1,n): | |
print "%s * %s = %s"%(seq[i],seq[j],seq[i]*seq[j]) |
View gist:1088833
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
#the wordlist file is the SCOWL wordlist downloaded from : http://wordlist.sourceforge.net/ | |
file = open("./SCOWL/wordlist.txt") | |
words =[line[:-1] for line in file.readlines()] #remove the newline character. | |
file.close() | |
#basic anagram comparion algorithm | |
def AreSameCharacters(word1,word2): | |
word1 = list(word1) |
View gist:2779865
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 agent(env, alpha, epsilon, initialQ, gamma, numberEp, alg): #the agent function | |
n_s = env.numStates | |
n_a = env.numActions | |
Q = initialQ * np.ones([n_s, n_a]) #initialize Q-table | |
epLength = [] #stores the episode length for plotting purposes | |
eps = 0 | |
while eps < numberEp: #run numberEp episodes | |
s = env.initState |
View insertionsort.py
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 insertionsort(A): | |
#we start loop at second element (index 1) since the first item is already sorted | |
for j in range(1,len(A)): | |
key = A[j] #The next item we are going to insert into the sorted section of the array | |
i = j-1 #the last item we are going to compare to | |
#now we keep moving the key back as long as it is smaller than the last item in the array | |
while (i > -1) and key < A[i]: #if i == -1 means that this key belongs at the start | |
A[i+1]=A[i] #move the last object compared one step ahead to make room for key | |
i=i-1 #observe the next item for next time. |
View cardinaldirections.js
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
/** | |
* Given "0-360" returns the nearest cardinal direction "N/NE/E/SE/S/SW/W/NW" | |
*/ | |
export function getCardinal(angle) { | |
/** | |
* Customize by changing the number of directions you have | |
* We have 8 | |
*/ | |
const degreePerDirection = 360 / 8; |
View gist:5607113
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(){ | |
// init code | |
}); |
View gist:5607130
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
var app = angular.module("myApp",["Directives","Controllers","Services"]; |
OlderNewer