Skip to content

Instantly share code, notes, and snippets.

View jjlumagbas's full-sized avatar

JJ Lumagbas jjlumagbas

View GitHub Profile
import junit.framework.TestCase;
import java.util.*;
public class ArrayListTest extends TestCase {
private final int INITIAL_CAPACITY = 5;
public void testAddOne() {
List<String> l = new ArrayList<String>();
l.add("Deodorant");
import junit.framework.TestCase;
/**
* A JUnit test case class.
* Every method starting with the word "test" will be called when running
* the test with JUnit.
*/
public class LListTest extends TestCase {
// 1. Determine if two numbers, x and y, are relatively prime. Compute for T(n) of your solution.
// Two integers are relatively prime if they share no common positive factors (divisors) except 1.
// 2. Compute for T(n):
for (int i = 1; i <= n; i++) {
a = x - y + 7 * b;
for (int j = 1; j <= n; j++) {
x = a + b;
for (int k = j; k <= n; k++) {
# Returns the larger value of either x or y, given x and y are numbers (Note: what value should be returned if they are equal?)
def max_of_2(x, y):
"""
Num, Num -> Num
Returns the larger of the two given numbers
public interface MyList {
public void add(Object item);
public void add(int i, Object item);
public Object get(int i);
public void remove(int i);
public void set(int i, Object item);
public class IteratorTest {
public static void main(String[] args) {
Collection<Integer> l = new LinkedList<Integer>();
l.add(1);
l.add(2);
l.add(5);
System.out.println(average(l));
System.out.println(countInRange(l, 0, 3));
}
for char in 'hello':
print('The character is', char)
import java.util.*;
public class LList implements MyList {
private MyNode head;
private int size;
public LList() {
size = 0;
}
def is_vowel(ch):
"""String -> Bool
Determines whether a single char string
is a vowel
"""
return ch == "a" or ch == "e" or ch == "i" or ch == "o" or ch == "u" or ch == "A" or ch == "E" or ch == "I" or ch == "O" or ch == "U"