Skip to content

Instantly share code, notes, and snippets.

@kamalbanga
kamalbanga / glift.cpp
Created April 8, 2014 19:48
GLIFT Simulation
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <queue>
#include <ctime>
#include <algorithm>
using namespace std;
@kamalbanga
kamalbanga / ACO2.py
Last active August 29, 2015 13:57
Vehicle Routing Problem
import random
import math
import numpy as np
seed = 1
boost = 20
maxIter = 50
numCities = 15
mu, sigma = 500, 200
demand = np.random.normal(mu,sigma,numCities)
@kamalbanga
kamalbanga / ACO.py
Last active March 29, 2017 10:23
To find TSP through Ant Colony Optimization
import random
import math
seed = 1
boost = 5
iter = 3
numCities = 4
maxDistance = 40000
upperX = 24000
upperY = 32000
@kamalbanga
kamalbanga / postorder.c
Last active December 27, 2015 11:59
Create Binary Tree from it's PostOrder when leaf nodes are differentiable from internal nodes and internal nodes have exactly two children.
#include <stdio.h>
#include <stdlib.h>
struct node
{
char c;
struct node* left, *right;
};
struct node* createNode(char c)
@kamalbanga
kamalbanga / numberofOnes.c
Last active December 26, 2015 03:19
Total no. of 1's in 2's complement representation between A and B, inclusive. Hackerrank's "2's complement" problem.
#include <stdio.h>
#include <math.h>
#include <limits.h>
unsigned int prevTwo(unsigned int x) // bit twiddling
{
unsigned int y = x;
x--;
x |= x >> 1;
x |= x >> 2;
@kamalbanga
kamalbanga / LegoBlocks.cpp
Last active March 10, 2019 17:37
A dynamic programming/recursive solution to Hackerrank's "Lego Blocks" problem.
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define MOD 1000000007
unsigned long long power(unsigned long long num, int p) {