Skip to content

Instantly share code, notes, and snippets.

View justjkk's full-sized avatar

J Kishore Kumar justjkk

  • Bangalore, India
View GitHub Profile
@justjkk
justjkk / cm.c
Created April 14, 2010 14:29
Conversion between Color Models(buggy)
// Conversion between color models(buggy)
/* Following is one of the best examples of how worse college given programs
can be. Proceed at your OWN RISK */
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{
int gd=DETECT,gm,n;
@justjkk
justjkk / nqueens.py
Created April 20, 2010 13:57 — forked from yuvipanda/nqueens.py
Recursive solution for N-Queens problem in Python
from math import *
import sys
chosen = {}
n = int(sys.argv[1])
def place(xpos, ypos):
if (ypos in chosen.values()):
return False
opponent = 1
@justjkk
justjkk / qsort.c
Created April 24, 2010 17:28
Implementation of Quicksort in C language
// Implementation of Quicksort in C language
#include<stdio.h>
int i,j,n,pivot,a[20];
void quick(int *a, int left, int right);
void swap(int *a, int i, int j);
void main()
{
int a[20];
printf("Enter the limits: ");
scanf("%d",&n);
@justjkk
justjkk / postfix.c
Created April 24, 2010 17:32
Evaluating postfix expression using Stack ADT
// Evaluating postfix expression using Stack ADT
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
typedef struct node
{
int data;
struct node *next;
}stack;
stack *topstk=NULL;
@justjkk
justjkk / heapsort.c
Created April 24, 2010 17:34
Implementing Heap Sort in C language
// Implementing Heap Sort in C language
#include<stdio.h>
void heap(int *a, int n);
void create_heap(int *a, int n);
void main()
{
int a[50],i,n;
printf("Enter the limits: ");
scanf("%d",&n);
printf("Enter the elements: ");
#!/bin/bash
#+-----------------------------------------------------------------------------+
#| Title : Bash Script to Download Selected Gists |
#| Author : jkk |
#| Date : 26-04-2010 |
#+-----------------------------------------------------------------------------+
if [ $# -eq 0 ] ; then
cat 1>&2 <<USAGE_TEXT
$0: missing gist id(s)
#!/bin/bash
echo Pinging 192.168.1.3 \
&& \
ping -c1 192.168.1.3 > /dev/null 2>&1 \
&& \
echo Ping Succeeded \
|| echo Ping Failed;
echo Press Enter key to exit...;
read;
@justjkk
justjkk / json-format.l
Created May 9, 2010 17:50
pretty-format json file using lex
/* Lex program to pretty-format json file. ***WARNING-Amateurish*** */
%{
int string=0;
int gi=0;
void indent(int i);
int prev_close=0;
%}
%%
\\\" { //Matching an escaped double quote
@justjkk
justjkk / Ackermann0.c
Created May 20, 2010 16:09
Ackermann's Function using C
// Ackermann's Function - Full Recursive
#include<stdio.h>
#include<stdlib.h>
int ackermann(int x, int y);
int count = 0, indent = 0;
int main(int argc, char **argv)
{
int x,y;
if(argc!=3)
{
@justjkk
justjkk / ack_short.py
Created May 20, 2010 18:43
Ackermann Function in python
import sys
count=0
sys.setrecursionlimit(50000)
cache={}
def a(m,n):
global count
global cache
count=count+1
if cache.has_key(m) and cache[m].has_key(n):
return cache[m][n]