generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
170 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# FRQ 2018 Q4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "java" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"public class FRQTwentyEighteen {\n", | ||
" public static int[] getComuln(int[][] arr2D, int c) {\n", | ||
" int [] result = new int[arr2d.length];\n", | ||
"\n", | ||
" for(int r = 0; r < arr2d.length;r++) {\n", | ||
" result[r] = arr2d[r][c];\n", | ||
" }\n", | ||
" return result;\n", | ||
" }\n", | ||
"\n", | ||
" public static boolean isLatin(int[][] square) {\n", | ||
" if (containsDuplicates(square[0])) {\n", | ||
" return false;\n", | ||
" }\n", | ||
" for (int r = 1; r < square.length; r++) {\n", | ||
" if (!hasAllValues(square[0],square[r])) {\n", | ||
" return false;\n", | ||
" }\n", | ||
" }\n", | ||
" for (int c = 0; c < sqaure[0].length; c++) {\n", | ||
" if (!hasAllValues(square[0], getColumn(square,c))) {\n", | ||
" return false;\n", | ||
" }\n", | ||
" }\n", | ||
" \n", | ||
" return true;\n", | ||
" }\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# FRQ 2017 Q4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "java" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"public class FRQTwentySeventeen {\n", | ||
" public static Position findPosition (int num, int[][] intArr) {\n", | ||
" for (int row=0; row <intArr.length; row++) {\n", | ||
" for (int col=0; col < intArr[0].length; col++) {\n", | ||
" if (intArr[row][col] == num) {\n", | ||
" return new Position (row,col);\n", | ||
" }\n", | ||
" }\n", | ||
" }\n", | ||
" return null;\n", | ||
" }\n", | ||
"\n", | ||
" public static Position[][] getSuccessorArray (int [][] intArr) {\n", | ||
" Position[][] newArr = new Position[intArr.length][intArr[0]];\n", | ||
"\n", | ||
" for (int row=0; row < intArr.length; row++) {\n", | ||
" for (int col=0; col < intarr[0].length; col++) {\n", | ||
" newArr[row][col] = findPosition(intArr[row][col]+1,intArr);\n", | ||
" }\n", | ||
" }\n", | ||
"\n", | ||
" return newArr;\n", | ||
" }\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# FRQ 2016 Q4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "java" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"public class FRQTwentySixteen {\n", | ||
" public static int totalLetters(List<String> wordList) {\n", | ||
" int total = 0;\n", | ||
"\n", | ||
" for (String word : wordList)\n", | ||
" {\n", | ||
" total += world.length;\n", | ||
" }\n", | ||
"\n", | ||
" return total;\n", | ||
" }\n", | ||
"\n", | ||
" public static int basicGapWidth (List<String> wordList, int formattedLen) {\n", | ||
" return (formattedLen - totalLetters(wordList) / (wordList.size() -1));\n", | ||
" }\n", | ||
"\n", | ||
" public static String format(List<String> wordList, int fomrattedLen) {\n", | ||
" String formatted = \"\";\n", | ||
" int gapWidth = basicGapWidth(wordList, fomrattedLen);\n", | ||
" int leftovers = leftoverSpaces(wordList, formattedLen);\n", | ||
"\n", | ||
" for (int w = 0; w < wordList.size() - 1; w++) {\n", | ||
" formatted = formatted + wordList.get(w);\n", | ||
" for(int i = 0; i < gapWidth; i++) {\n", | ||
" formatted = formatted + \"\";\n", | ||
" }\n", | ||
" if (leftovers > 0) {\n", | ||
" formatted = formatted + \"\";\n", | ||
" leftovers--;\n", | ||
" }\n", | ||
" formatted = formatted + wordList.get(wordList.size() -1);\n", | ||
" }\n", | ||
"\n", | ||
" return formatted;\n", | ||
" }\n", | ||
"}" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Java", | ||
"language": "java", | ||
"name": "java" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "java", | ||
"file_extension": ".jshell", | ||
"mimetype": "text/x-java-source", | ||
"name": "Java", | ||
"pygments_lexer": "java", | ||
"version": "17.0.5+8-Ubuntu-2ubuntu120.04" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |