Skip to content

Instantly share code, notes, and snippets.

View manudatta's full-sized avatar

Manu Datta manudatta

  • Singapore
View GitHub Profile
@manudatta
manudatta / zero_one_knapsack.py
Created January 11, 2020 14:24
0-1 knapsack implementation in python
# 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)
# 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)
@manudatta
manudatta / main.py
Last active January 16, 2021 07:59
parsing and printing guarantees
#!/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"