Algorithms – Counting split inversions and Quicksort

April 1, 2012

I’ve been casually listening to a bunch of the video lectures for Stanford’s algorithm class, and the first two weeks programming challenges are pretty good if you haven’t checked them out yet. I won’t spoil the suspense in publishing the code – as I think that’s the point of these exercises, but the lectures do [...]

Read the full article →

Generating Pythagorean triples

March 19, 2012

I’ve been researching Pythagorean triplets for a Project Euler problem. Here’s an interesting article in wikipedia on using a Ternary Tree to generate primitive Pythagorean triples. I experimented writing the code for this generator (see below): # tree of primitive pythagorean triples import math from numpy import * # let’s generate ternary tree of pythagorean [...]

Read the full article →

Reference: NumPy for Matlab Users

March 19, 2012

http://www.scipy.org/NumPy_for_Matlab_Users#head-e9a492daa18afcd86e84e07cd2824a9b1b651935

Read the full article →

Project Euler 86 – Exploring the shortest path from opposite corners of a cuboid

February 1, 2012

http://projecteuler.net/problem=86 #euler 86 import math import time t0 = time.time() def gcd(a,b): while b!= 0: a, b = b, a%b return a def isCoprime(a,b): if gcd(a,b) == 1: return True else: return False mlimit = 65 # generate a list of primitives prim = [] for m in range(2, mlimit): for n in range(1, m): [...]

Read the full article →

Linked Lists video lecture – UC Berkeley

January 30, 2012
Read the full article →

Video: 3 Big Data Tech Talks You Can’t Miss

January 30, 2012

Would like to watch these someday…. http://engineering.linkedin.com/event/video-3-big-data-tech-talks-you-can%E2%80%99t-miss

Read the full article →

Project Euler 83 – Minimal path sums using Dijkstra’s algorithm

January 27, 2012

http://projecteuler.net/problem=83 I used the pseudocode from Wikipedia on Dijkstra’s algorithm to solve this problem. # euler 82 # grid is a dictionary with key as tuple (i,j) and value as value of node # i is row, j is column of grid import time t0 = time.time() f = open(‘matrix.txt’, ‘r’) grid = {} counter [...]

Read the full article →

Python: get key with the least value from a dictionary

January 27, 2012

From StackOverflow: http://stackoverflow.com/questions/3282823/python-get-key-with-the-least-value-from-a-dictionary min(d, key=d.get)

Read the full article →