Skip to content

Instantly share code, notes, and snippets.

@bknarendra
bknarendra / gist:2692488
Created May 14, 2012 07:37
Codercharts:Word Lazy swap
import java.io.*;
import java.util.*;
public class word_lazy_swap
{
public static HashSet<String>dict;
public static void main(String[] args) throws Exception
{
InputReader sc=new InputReader(new FileInputStream(args[0]));
dict=new HashSet<String>();
while(!sc.isExhausted()) dict.add(sc.readLine());
@bknarendra
bknarendra / gist:2692498
Created May 14, 2012 07:40
CoderCharts:It's raining anagrams
import java.util.*;
import java.io.*;
public class its_raining_anagrams
{
public static short[]profile(String s)
{
int i,n=s.length();
short arr[]=new short[26];
for(i=0;i<n;i++)
arr[s.charAt(i)-'A']++;
@bknarendra
bknarendra / gist:2692503
Created May 14, 2012 07:40
CoderCharts:Sum It Up 3
// For java, make sure the main class name is sum_it_3
import java.io.*;
import java.util.*;
public class sum_it_3 {
public static void main(String[] args) throws Exception {
InputReader sc=new InputReader(new FileInputStream(args[0]));
int i=0,j,k,l,max=-1,sum=0;
int a[]=new int[10000000];
while(!sc.isExhausted())
a[i++]=sc.readInt();
@bknarendra
bknarendra / gist:2692505
Created May 14, 2012 07:42
CoderCharts:Word Twist
import java.io.*;
import java.util.*;
public class word_twist
{
private static final int ALPHABET = 26;
public static int[] profile(String s) {
int[] cnt = new int[ALPHABET];
for (int i = 0; i < s.length(); i++)
++cnt[s.charAt(i)-'A'];
@bknarendra
bknarendra / gist:2692514
Created May 14, 2012 07:44
CoderCharts:Sum It Up 4
// For java, make sure the main class name is sum_it_4
import java.io.*;
import java.util.*;
public class sum_it_4
{
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(new File(args[0]));
Vector <Integer>v=new Vector<Integer>();
int i=0,j,k;
while(Boolean.TRUE)
@bknarendra
bknarendra / gist:2692520
Created May 14, 2012 07:45
CoderCharts:Bits Manipulation
import java.io.*;
import java.util.*;
public class bits_manipulation
{
public static void main(String[] args) throws Exception
{
Scanner sc=new Scanner(new File(args[0]));
long a,res=0;int x,i=0;
while(sc.hasNext())
{
@bknarendra
bknarendra / gist:2692522
Created May 14, 2012 07:45
CoderCharts:Coin Changes
import java.util.*;
import java.io.*;
public class coin_changes
{
public static void main (String[] args) throws Exception
{
int max=-1,i,j;
Scanner sc=new Scanner(new File(args[0]));
Vector <Integer>v=new Vector<Integer>();
while(sc.hasNext())
@bknarendra
bknarendra / gist:2692525
Created May 14, 2012 07:47
CoderCharts:Crosswords
import java.util.*;
import java.io.*;
class Node {
char content;
boolean marker;
Collection<Node> child;
public Node(char c){
child = new LinkedList<Node>();
marker = false;
content = c;
import java.util.*;
import java.io.*;
public class AddAGram{
public static Vector<String>dic[];
public static Stack<String>s;
public static HashSet<String>vis=new HashSet<String>();
public static boolean check(char []l,char []s){
int i,j,len=l.length;
for(i=0;i<s.length;i++)
for(j=0;j<l.length;j++)
@bknarendra
bknarendra / gist:3072072
Created July 8, 2012 18:01
Levenshtein distance
import java.io.*;
import java.util.*;
public class levenshtein_distance{
public static HashSet[]h=new HashSet[25];
public static Stack<String>st=new Stack<String>();
public static HashSet<String>fnl=new HashSet<String>();
public static void main(String args[]) throws Exception{
long aa=System.currentTimeMillis();
InputReader sc=new InputReader(new FileInputStream("in.txt"));
int i,j;