Skip to content

Instantly share code, notes, and snippets.

View karthick18's full-sized avatar

A R Karthick karthick18

View GitHub Profile
@karthick18
karthick18 / Makefile
Created May 2, 2011 08:16
A parallel sort but currently using just 1 intermediate input and output files for merging sort results
CC := gcc
CFLAGS := -Wall -g -std=c99
LD_LIBS := -lpthread
ARCH := $(shell uname)
BLOCK_SIZE := 1m
ifeq ("$(strip $(ARCH))", "Linux")
LD_LIBS += -lrt
BLOCK_SIZE := 1M
endif
SRCS := prsort.c
@karthick18
karthick18 / large_fact.c
Created December 12, 2012 07:26
Solution for large factorial problem accepted at: http://hackerearth.com/hackerearth-practice-challenge/p-6/ Should compute any factorial. Tested up to fact(250000) with an output of 1.24 million digits. Runs slowly when over fact(10000)
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#define likely(expr) __builtin_expect(!!(expr), 1)
#define unlikely(expr) __builtin_expect(!!(expr), 0)
#define __EXTEND_MEM (256<<10)