Skip to content

Instantly share code, notes, and snippets.

@pratikone
pratikone / MultiplyMillion-Memory.c
Created December 11, 2013 09:41
C code to multiply 2 million-digit numbers
//
// main.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>
@pratikone
pratikone / MultiplyMilion-File.c
Created December 11, 2013 09:43
Multiply 2 million-digit numbers using files I/O
//
// simple.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@pratikone
pratikone / temp.c
Created December 15, 2013 18:38
tep
//
// main.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>
@pratikone
pratikone / bfs2way.py
Last active August 29, 2015 14:08
BFS - 2 way search code
import rubik
import unittest
def shortest_path(start, end):
"""
Using 2-way BFS, finds the shortest path from start_position to
end_position. Returns a list of moves.
You can use the rubik.quarter_twists move set.
Each move can be applied using rubik.perm_apply
"""
@pratikone
pratikone / fb_hackercup2016_boomerang.py
Last active January 30, 2016 05:38
Solution for Facebook hacker cup 2016 Boomerang question https://www.facebook.com/hackercup/problem/910374079035613/
from datetime import datetime
def reading_input(file, teja):
with open(file) as w:
content = w.readlines()
ctr = 0
boomerangs = []
nights = content[0] #ignoring this value as we can print without nights
# Source : http://www.geeksforgeeks.org/maximum-product-subarray/
def maxProd(input):
prod = temp_prod = 1
i=0
negativeCount = 1
start_SubArray = -1
end_SubArray = -1
while i < len(input) :
@pratikone
pratikone / knapsack.c
Last active July 26, 2016 17:07
OpenCL knapsack implementation - host and kernel files
// The code is based on needle.c for Needleman-Wunsch algorithm at
// https://github.com/vtsynergy/OpenDwarfs/blob/master/dynamic-programming/nw/needle.c
#define LIMIT -999
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "needle.h"
#include <sys/time.h>
@pratikone
pratikone / blosum.py
Last active October 25, 2016 00:58
Create blosum matrix with 5 alignments
##########################
# Author : Pratik Anand #
##########################
from sets import Set
from math import log
from decimal import *
from tabulate import tabulate
import copy
@pratikone
pratikone / global_affinity_alignment.py
Last active October 25, 2016 00:58
Global alignment with affinity
##########################
# Author : Pratik Anand #
##########################
from tabulate import tabulate
import copy
class Obj :
data = 0
x = 0
y = 0
@pratikone
pratikone / global_local_alignment
Last active October 25, 2016 00:35
Global and local alignments
##########################
# Author : Pratik Anand #
##########################
from tabulate import tabulate
import copy
IS_LOCAL_ALIGNMENT = False
USE_BLOSUM = False
match = 1
mismatch = -1