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 random | |
import math | |
import copy | |
def euclid(a,b): | |
'''returns the Greatest Common Divisor of a and b''' | |
a = abs(a) | |
b = abs(b) |
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
package edu.cmu.cs771.hw1; | |
/** | |
* The class DoubleNode holds two pointers and a character. It is used to represent a single node on a double linked list. | |
* @author songluo | |
* | |
*/ | |
public class DoubleNode { | |
private DoubleNode prev; | |
private DoubleNode next; |
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
package edu.cmu.cs771.hw1; | |
/** | |
* This class implements a doubly linked list of characters in Java. | |
* The instance variables head and tail are initially null. | |
* As elements are added head points to the first element on the list and tail points to the last element. Each node on the list is of type DoubleNode. | |
* Each DoubleNode holds a pointer to the previous node and a pointer to the next node in the list. | |
* @author songluo | |
* | |
*/ |
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
package edu.cmu.cs771.hw1; | |
/** | |
* Class EmptyListException definition. | |
* @author songluo | |
* | |
*/ | |
public class EmptyListException extends RuntimeException{ | |
/** |
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
package edu.cmu.cs771.hw1; | |
import java.nio.charset.Charset; | |
import java.util.*; | |
import java.math.BigInteger; | |
/** | |
* @author songluo | |
* | |
*/ |
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
package edu.cmu.cs771.hw1; | |
import java.nio.charset.Charset; | |
import java.util.*; | |
import java.math.BigInteger; | |
public class MerkleHellmanKnapsackTest { | |
public MerkleHellmanKnapsackTest() { | |
// TODO Auto-generated constructor stub |
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
## {{{ http://code.activestate.com/recipes/366178/ (r5) | |
def primes(n): | |
if n==2: return [2] | |
elif n<2: return [] | |
s=range(3,n+1,2) | |
mroot = n ** 0.5 | |
half=(n+1)/2-1 | |
i=0 | |
m=3 | |
while m <= mroot: |
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 <unistd.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char *argv[]) | |
{ | |
int i =0; | |
char *memPtr=NULL; | |
char *memPtr2G=NULL; | |
int j=0; |
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 <stdio.h> | |
#include <string.h> | |
#include <netinet/in.h> | |
#include <event2/event.h> | |
#include <sys/socket.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) | |
{ | |
int i; |
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
==7307== Memcheck, a memory error detector | |
==7307== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. | |
==7307== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info | |
==7307== Command: ./a.out | |
==7307== | |
Starting Libevent 2.0.20-stable. | |
Available methods are: | |
epoll | |
poll | |
select |
OlderNewer