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
#!/usr/bin/env python3 | |
import csv | |
import sys | |
from collections import namedtuple | |
from datetime import datetime | |
Guarantee = namedtuple("Guarantee", "end_date address") | |
DEFAULT_CALCULATION_DATE = datetime(2020, 5, 2) | |
DEFULAT_FILE_NAME = "./guarantees_end.csv" |
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: [email protected] | |
# balanced partition problem | |
def solution(A): | |
a = list(map(abs,A)) # specific to codility problem | |
L = len(a) | |
if L == 1: | |
return a[0] | |
array_sum = sum(a) | |
half,m = divmod(array_sum,2) | |
#print(half,m) |
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: [email protected] | |
# zero-one knapsack implementation in python | |
items = { | |
'a': (12,4) | |
,'b':(10,6) | |
,'c':(8,5) | |
,'d':(11,7) | |
,'e':(14,3) |
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): |
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
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
#! 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
-- 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
% 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
;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)))) |
NewerOlder