This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string, random | |
letters = (list(string.ascii_letters)) | |
numbers = [n for n in string.digits] | |
alphanumeric = (letters + numbers) | |
genlen = 12 | |
result = random.sample(alphanumeric, genlen) | |
print("".join(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.InputStreamReader; | |
import java.util.StringTokenizer; | |
import java.util.LinkedList; | |
import java.util.Stack; | |
/* | |
* WIP : order based methods | |
* min, max, floor, ceiling, selection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Huffman{ | |
private int N; | |
private PriorityQueue<Node> pq; | |
private Node root; | |
public Huffman(String[] s, int[] freq){ | |
N = s.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class f{ | |
public static int max(int x, int y){ | |
return (x > y) ? x : y; | |
} | |
public static int min(int x, int y){ | |
return (x < y) ? x : y; | |
} | |
public static void main(String [] args){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cmath> | |
typedef long long ll; | |
//Returns length of integer | |
int len(int n){ | |
return (n == 0 ? 1 : (int)(log10(n)+1)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Vector<String> mergeSort(Vector<String> v){ | |
int sz = v.size(); | |
if (sz > 1){ | |
int m = sz >>> 1; | |
Vector<String> leftList = new Vector<String>(); | |
Vector<String> rightList = new Vector<String>(); | |
int n; | |
for (n=0; n<m; n++) leftList.add(v.elementAt(n)); | |
for (n=m; n<sz; n++) rightList.add(v.elementAt(n)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean checkAnagram(String s1, String s2){ | |
if (s1.length() != s2.length()) return false; | |
int wt1 = 0, wt2 = 0, i; | |
for (i=0; i<s1.length(); i++) wt1+=(int)(s1.charAt(i)); | |
for (i=0; i<s2.length(); i++) wt2+=(int)(s2.charAt(i)); | |
return wt1 == wt2; | |
} |
NewerOlder