Class CodeCamp

java.lang.Object
  extended by CodeCamp

public class CodeCamp
extends Object


Constructor Summary
CodeCamp()
           
 
Method Summary
static int getValueOfMostValuablePlot(int[][] city)
          Given a 2D array of ints return the value of the most valuable contigous sub rectangle in the 2D array.
static int hammingDistance(int[] aList, int[] bList)
          Determine the Hamming distance between two arrays of ints.
static boolean isPermutation(int[] listA, int[] listB)
          Determine if one array of ints is a permutation of another.
static int mostVowels(String[] list)
          Determine the index of the String that has the largest number of vowels.
static boolean queensAreSafe(char[][] board)
          Determine if the chess board represented by board is a safe set up.
static int sharedBirthdays(int numPeople, int numDaysInYear)
          Perform an experiment simulating the birthday problem.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeCamp

public CodeCamp()
Method Detail

hammingDistance

public static int hammingDistance(int[] aList,
                                  int[] bList)
Determine the Hamming distance between two arrays of ints. Neither the parameter aList or bList are altered as a result of this method.

Parameters:
aList - != null, aList.length == bList.length
bList - != null, bList.length == aList.length
Returns:
the Hamming Distance between the two arrays of ints.

isPermutation

public static boolean isPermutation(int[] listA,
                                    int[] listB)
Determine if one array of ints is a permutation of another. Neither the parameter listA or the parameter listB are altered as a result of this method.

Parameters:
listA - != null
listB - != null
Returns:
true if listB is a permutation of listA, false otherwise

mostVowels

public static int mostVowels(String[] list)
Determine the index of the String that has the largest number of vowels. Vowels are defined as 'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', and 'u'. The parameter list is not altered as a result of this method.

pre: list != null, list.length > 0, there is an least 1 non null element in list

post: return the index of the non-null element in list that has the largest number of characters that are vowels. If there is a tie return the index closest to zero. The empty String, "", has zero vowels. It is possible for the maximum number of vowels to be 0.

Parameters:
list - the array to check
Returns:
the index of the non-null element in list that has the largest number of vowels.

sharedBirthdays

public static int sharedBirthdays(int numPeople,
                                  int numDaysInYear)
Perform an experiment simulating the birthday problem. Pick random birthdays for the given number of people. Return the number of pairs of people that share the same birthday.

Parameters:
numPeople - The number of people in the experiment. This value must be > 0
numDaysInYear - The number of days in the year for this experiement. This value must be > 0
Returns:
The number of pairs of people that share a birthday after running the simulation.

queensAreSafe

public static boolean queensAreSafe(char[][] board)
Determine if the chess board represented by board is a safe set up.

pre: board != null, board.length > 0, board is a square matrix. (In other words all rows in board have board.length columns.), all elements of board == 'q' or '.'. 'q's represent queens, '.'s represent open spaces.

post: return true if the configuration of board is safe, that is no queen can attack any other queen on the board. false otherwise. the parameter board is not altered as a result of this method.

Parameters:
board - the chessboard
Returns:
true if the configuration of board is safe, that is no queen can attack any other queen on the board. false otherwise.

getValueOfMostValuablePlot

public static int getValueOfMostValuablePlot(int[][] city)
Given a 2D array of ints return the value of the most valuable contigous sub rectangle in the 2D array. The sub rectangle must be at lest 1 by 1.

pre: mat != null, mat.length > 0, mat[0].length > 0, mat is a rectangular matrix.

post: return the value of the most valuable contigous sub rectangle in city.

Parameters:
city - The 2D array of ints representing the value of each block in a portion of a city.
Returns:
return the value of the most valuable contigous sub rectangle in city.