FRQ 2018 Q4
public class FRQTwentyEighteen {
public static int[] getComuln(int[][] arr2D, int c) {
int [] result = new int[arr2d.length];
for(int r = 0; r < arr2d.length;r++) {
result[r] = arr2d[r][c];
}
return result;
}
public static boolean isLatin(int[][] square) {
if (containsDuplicates(square[0])) {
return false;
}
for (int r = 1; r < square.length; r++) {
if (!hasAllValues(square[0],square[r])) {
return false;
}
}
for (int c = 0; c < sqaure[0].length; c++) {
if (!hasAllValues(square[0], getColumn(square,c))) {
return false;
}
}
return true;
}
}
public class FRQTwentySeventeen {
public static Position findPosition (int num, int[][] intArr) {
for (int row=0; row <intArr.length; row++) {
for (int col=0; col < intArr[0].length; col++) {
if (intArr[row][col] == num) {
return new Position (row,col);
}
}
}
return null;
}
public static Position[][] getSuccessorArray (int [][] intArr) {
Position[][] newArr = new Position[intArr.length][intArr[0]];
for (int row=0; row < intArr.length; row++) {
for (int col=0; col < intarr[0].length; col++) {
newArr[row][col] = findPosition(intArr[row][col]+1,intArr);
}
}
return newArr;
}
}
public class FRQTwentySixteen {
public static int totalLetters(List<String> wordList) {
int total = 0;
for (String word : wordList)
{
total += world.length;
}
return total;
}
public static int basicGapWidth (List<String> wordList, int formattedLen) {
return (formattedLen - totalLetters(wordList) / (wordList.size() -1));
}
public static String format(List<String> wordList, int fomrattedLen) {
String formatted = "";
int gapWidth = basicGapWidth(wordList, fomrattedLen);
int leftovers = leftoverSpaces(wordList, formattedLen);
for (int w = 0; w < wordList.size() - 1; w++) {
formatted = formatted + wordList.get(w);
for(int i = 0; i < gapWidth; i++) {
formatted = formatted + "";
}
if (leftovers > 0) {
formatted = formatted + "";
leftovers--;
}
formatted = formatted + wordList.get(wordList.size() -1);
}
return formatted;
}
}