Skip to content

Instantly share code, notes, and snippets.

View basarat's full-sized avatar
🌹
youtube.com/basaratali

Basarat Ali Syed basarat

🌹
youtube.com/basaratali
View GitHub Profile
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])
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])
#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)
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
$(function(){
// init code
});
var app = angular.module("myApp",["Directives","Controllers","Services"];
@basarat
basarat / gist.ts
Last active January 18, 2016 16:38
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);
}
extend({foo:123},b());
function b(){
return [
{foo:123},
{bar:456}
];
}
extend({foo:123},b());
function b(){
return extend(
{foo:123},
{bar:456}
);
}
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) {