This file contains hidden or 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
# Copyright 2002 Manu Datta | |
# All rights reserved | |
.data | |
adjMatrix: .space 450 | |
.align 2 | |
count: .space 225 | |
#msg1: .asciiz "Error in toplogical sort:\n" | |
#msg2: .asciiz "graph contanis a cycle\n" | |
msg3: .asciiz "Vertex : " |
This file contains hidden or 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
# Copyright 2002 Manu Datta (gmail.com ID Manu dot Datta) | |
# All rights reserved | |
.data | |
msg1: .asciiz "\nEnter integer values followed by return (-1 terminates input): \n" | |
msg2: .asciiz "," | |
msg3: .asciiz "Bubble Sort" | |
msg4: .asciiz "#########pass#########" | |
msg5: .asciiz "\n" | |
msg6: .asciiz "\nNumber list has been sorted\n" |
This file contains hidden or 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
;pg 102. Ex 3.22.c | |
(defn myfun [x y] (list (list x) y)) | |
(myfun 'alpha 'beta) | |
;.d | |
(defn firstp? [ e collection] (= e (first collection)))--clojure uses ? instead of p for predicate (lisp convention) | |
(firstp? 'foo '(foo bar baz)) | |
(firstp? 'boing '(foo bar baz)) -- clojure has false instead of nil | |
;.e | |
(defn mid-add1 [sentence] (list (first sentence) (+ 1 (second sentence)) (last sentence))) | |
(mid-add1 '(take 2 cookies)) |
This file contains hidden or 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
;pg 151 | |
(defn throw-die [] (+ 1 (rand-int 6))) | |
(defn throw-dice [] (list (throw-die) (throw-die))) | |
(throw-dice) | |
(defn snake-eyes? [dice-throw] (= '(1 1) dice-throw)) | |
(snake-eyes? '(3 1)) | |
(defn boxcar? [dice-throw] (= '(6 6) dice-throw)) | |
(boxcar? '(6 6)) | |
; intro of let | |
(defn instant-win? [dice-throw] (let [dice-throw-sum (reduce + dice-throw)] (or (= 7 dice-throw-sum) (= 11 dice-throw-sum)))) |
This file contains hidden or 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
% Author: Manu Dot Datta At Gmail dot com | |
-module(p99). | |
-compile(export_all).% 1.26 | |
%1.26 | |
% Generate the combinations of K distinct objects chosen from the N elements of a list | |
% usage: p99:combination(N,List) N < length(L) is length of combinations | |
% example: | |
%p99:combination(3,[a,b,c]). => [[a,b,c],[a,c,b],[b,a,c],[b,c,a],[c,a,b],[c,b,a]] |
This file contains hidden or 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
-- Copy right (c) Manu dot Datta @ gmail dot com | |
.data | |
msg1: .asciiz "Enter a positive index for Fibonacci Calculation : " | |
msg2: .asciiz "The Finonacci number is : " | |
msg3: .asciiz "Recusive calls made to Fibonacci : " | |
msgerr1: .asciiz "The Finonacci number is : 1 \n" | |
msgerr2: .asciiz "Recusive calls made to Fibonacci : 0 \n" | |
nl: .asciiz "\n"; |
This file contains hidden or 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
#! path to python | |
# copyright manu.datta gmail.com | |
import string | |
import getopt | |
import sys | |
import ConfigParser | |
import re | |
UsageErr ='googlerank -n <number> -d <website> -c <domain> <Search Word>' |
This file contains hidden or 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 ones(): | |
return 1,lambda : ones() | |
def power_of_two(x=1): | |
return x,lambda : power_of_two(x*2) | |
def fibonacci(xcurr=1,xlast=0): | |
xnext = xcurr+xlast | |
return xnext,lambda : fibonacci(xnext,xcurr) | |
def list_iter(l=[]): | |
if len(l) == 0 : | |
raise StopIteration |
This file contains hidden or 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
import copy | |
import sys | |
def greater_path(path1,path2): | |
(path_list1,elevation1,last_heightl1) = path1 | |
(path_list2,elevation2,last_heightl2) = path2 | |
len1 = len(path_list1) | |
len2 = len(path_list2) | |
if len1 != len2: | |
return len1 > len2 | |
return elevation1 > elevation2 |
This file contains hidden or 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
""" | |
CDMA: encoding decoding in python | |
Author: [email protected] | |
""" | |
import itertools | |
import operator | |
def mux(codes,data): |
OlderNewer