Skip to content

Instantly share code, notes, and snippets.

/***************Dijkstras shortest Path Algorithm ************************/
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1000
class node{
public:
/******************************KRUSKALS ALGORITHM********************************/
#include<iostream>
#include<set>
#include<algorithm>
#include<queue>
#include<utility>
#include<exception>
#include<conio.h>
using namespace std;
#include<iostream>
#define sqr(a) ((a)*(a))
using namespace std;
unsigned long sqrt(unsigned long a){
unsigned long l=0,u=a,mid = l+(u-l)/2;
while(mid*mid != a){
if(sqr(mid) < a){
if(sqr(mid+1)>a){
return mid;
}
#include<iostream>
using namespace std;
void move(int n,char* src,char* dest,char* buffer)
{
if(n==2){
cout<<"\n1,\t"<<src<<" -->"<<buffer;
cout<<"\n2,\t"<<src<<" -->"<<dest;
cout<<"\n1,\t"<<buffer<<" -->"<<dest;
import re
import urllib2
from os import system
lecture='https://class.coursera.org/android-001/lecture'
content=urllib2.urlopen(lecture).read()
sub=re.compile(r'https://class.coursera\.org/android-001/lecture/subtitles\?q=[0-9]+_en\&format=srt')
vid=re.compile(r'https://class\.coursera\.org/android-001/lecture/download\.mp4\?lecture_id=[0-9]+')
for i in sub.findall(content):
#!/usr/bin/python
import re
import urllib2
from os import system
from sys import argv
if len(argv) != 2:
print "The format is incorrect"
exit(0)
lecture=argv[1]
#!/usr/bin/python
import requests
from sys import argv
def get_distance(origin,destination):
gmap='http://maps.googleapis.com/maps/api/distancematrix/json'
payload={"origins":origin,"destinations":destination,"sensor":'false' }
try:
a=requests.get(gmap,params=payload)
data = a.json()
origin = str(data['origin_addresses'][0])
--sorting algorithm inspired from quick sort in haskel
ksort :: [Int]->[Int]
ksort [] = []
ksort (k:a) = ksort [i|i<-a,i<=k]++(k:(ksort [i|i<-a,i>k]) )
main = do
input <- getLine
let output::[Int]
output = read input
putStrLn (show (ksort output ))
--fuinction to get the square of an integer
square::Int->Int
square a = a*a
--function to find the mid of two integers floor to ,lower if fractional
mid::Int->Int->Int
mid a b = (a+b) `div` 2
#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/bin/vimdiff"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}