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]) |
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]) |
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) |
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 |
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 | |
}); |
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"]; |
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
export function extend(...args: any[]):any { | |
var extendRecursive = (x:any[], extractFields:(y)=>void) => { | |
for (let obj of x) { | |
if (obj) { | |
if (obj instanceof Array) { | |
extendRecursive(obj, extractFields) | |
} | |
else { | |
extractFields(obj); | |
} |
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
extend({foo:123},b()); | |
function b(){ | |
return [ | |
{foo:123}, | |
{bar:456} | |
]; | |
} |
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
extend({foo:123},b()); | |
function b(){ | |
return extend( | |
{foo:123}, | |
{bar:456} | |
); | |
} |
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
export function extend(...args: any[]):any { | |
let extractFields = obj => { | |
for (let key in obj) { | |
//copy all the fields | |
newObj[key] = obj[key]; | |
} | |
} | |
var extendRecursive = (x:any[]) => { | |
for (let obj of x) { |