Problem Set 1
Due by 11:59 p.m. Eastern time on June 30, 2026. See below for a summary of the policies regarding late submissions.
Preliminaries
Homework is due by 11:59 p.m. Eastern time on the stated due date. If it is submitted more than 10 minutes after that time, it will be considered a full day late. There will be a 10% deduction for submissions that are up to one day late, and a 20% deduction for submissions that are 2 or 3 days late. We will not accept any homework that is more than 3 days late. Plan your time carefully, and don’t wait until the last minute to begin an assignment. Starting early will give you ample time to ask questions and obtain assistance.
In your work on this assignment, make sure to abide by our policies on academic conduct.
If you haven’t already done so, you should complete Problem Set 0 before beginning this assignment.
If you have questions while working on this assignment, please come to
office hours, post them on Ed Discussion, or email
cscie22-staff@lists.fas.harvard.edu
Part I: Short-answer problems
40 points total
Creating the necessary folder
-
If you haven’t already created a folder named
s22for your work in this course, follow these instructions to do so. -
Then create a subfolder called
ps1within yours22folder, and put all of the files for this assignment in that folder.
Creating the necessary file
The problems from Part I will all be completed in a single PDF file. To create it, you should do the following:
-
Access the template that we have created by clicking on this link and signing into your Google account as needed.
-
When asked, click on the Make a copy button, which will save a copy of the template file to your Google Drive.
-
Select File->Rename, and change the name of the file to
ps1_partI. -
Add your work for the problems from Part I to this file.
-
Once you have completed all of these problems, choose File->Download->PDF document, and save the PDF file in your
ps1folder. The resulting PDF file (ps1_partI.pdf) is the one that you will submit. See the submission guidelines at the end of Part I.
Problem 1: Memory management and arrays
8 points
Java built-in classes
In your work on this and subsequent problem sets, you
should not use any of Java’s built-in collection classes
(e.g., ArrayList) or utility classes (e.g., Arrays),
unless a problem explicitly states that you may do so.
Consider the following lines of Java code:
int[] a = {5, 4, 3, 2, 1};
int[] b = {5, 4, 3, 2, 1};
int[] c = a;
for (int i = 0; i < b.length; i++) {
c[i] = b[i];
}
b[3] += b.length;
a[3]--;
System.out.println(a[3] + " " + b[3] + " " + c[3]);
-
(6 points) In
ps1_partI(see above), we have given you the beginnings of a memory diagram for these lines of code. It includes both the stack and the heap.On the stack, we have included a stack frame for the
mainmethod, which is where we are assume that the above lines are found. On the heap, we have included the array to which the variablearefers.Complete the provided memory diagram so that it shows the final result of the above lines of code.
To do so, you should:
-
Click on the diagram and then click the Edit link that appears below the diagram.
-
Make whatever changes are needed to the diagram. Below the thick horizontal line, we have given you a set of extra components that you can use as needed by dragging them above the thick line and putting them in the correct position. You may not need all of the provided components.
-
You can also edit any of the values in an array by clicking on one of its cells and editing the text that is inside the cell.
-
Once you have made all of the necessary changes, click the Save & Close button.
-
-
(2 points) Indicate what will be printed by the final line of code shown above.
Problem 2: Array practice
10 points total; 5 points each part
In this problem, you will write static methods that operate on arrays. These methods do not need to use recursion, and they do not need to be implemented as part of a class. Simply include the methods with your answers for the other problems from Part I.
-
Write a method with the header
public static boolean anyMult(int[] arr, int n)that takes a reference to an array of integers and returns
trueif at least one of the values in the array is a multiple ofn, andfalseotherwise.Special cases:
-
If the method is passed a value of
null, it should throw anIllegalArgumentException. -
If the method is passed an array with a length of 0, it should return
false.
See below for a recommended approach to testing this method.
-
-
Write a method with the header
public static void shiftRight(int[] arr)that takes a reference to an array of integers and shifts all of the array elements one position to the right, with the original last element wrapping around to become the new first element. For example, consider this array:
int[] values = {0, 2, 4, 6, 8, 10};After calling
shiftRight(values), the contents of the values array should be{10, 0, 2, 4, 6, 8}.Note that the method has a return type of
void, which means that it should not return a value. It doesn’t need to do so, because it should be modifying the internals of the arrayarr, and thus those changes will still be there after the method returns.Special cases:
-
If the method is passed a value of
null, it should throw anIllegalArgumentException. -
If the method is passed an array with a length of 0 or 1, it should leave the array unchanged.
-
-
Testing Your Methods in VSCodium We encourage you to use VSCodium to test your methods for parts 1 and 2 above. Here are the steps:
-
If you haven’t already done so, create a folder named
ps1for your work on this assignment. -
Download the following file:
Problem2Test.javaMake sure to put the file in your
ps1folder. If your browser doesn’t allow you to specify where the file should be saved, try right-clicking on the link above and choosing Save as… or Save link as…, which should produce a dialog box that allows you to choose the correct folder for the file. -
In VSCodium, select the File->Open Folder menu option, and use the resulting dialog box to find and open the folder that you created for this assignment. (Note: You must open the folder; it is not sufficient to simply open the file.)
The name of the folder should appear in the Explorer pane on the left-hand side of the VSCodium window, along with the name of the
Problem2Test.javafile that you downloaded above. -
Click on the name
Problem2Test.java, which will open an editor window for that file. -
Put your methods inside the provided class. We have given you some code in the
mainmethod for testing your methods, but we encourage you to add additional tests as well.Note: You may use the
Arrays.toString()method for testing, since it allows to easily view the contents of an array. However, you should not be using this method or any other method from theArraysclass for any purpose other than testing. -
Open VSCodium’s built-in Terminal pane. You can do this by pressing the Control key and the backtick key, or by selecting Terminal->New Terminal from the menu. The Terminal should open at the bottom of the VSCodium window. It should already be in the
ps1folder. -
Compile your program:
-
Save the changes that you made to the file by selecting File->Save or using Ctrl-S.
-
Type the following command in the Terminal and then press Enter:
javac Problem2.javaDoing so word will produce a list of any syntax errors in the code.
Notes:
-
Each error message includes the line number of the code that produced the error. For example, let’s say that you see an error message that begins with the following
Problem2.java:5: error: ...The
:5that comes after the name of the file tells you that the error is on line 5 of the file. -
If you press the Ctrl key as you click on the line number in an error message, the corresponding line of code should be highlighted in the editor window.
-
-
-
Continue editing the code and recompiling until
javacdoes not report any errors. Important: Make sure to save any changes that you make before you try to recompile! -
Run the program: Once all of the syntax errors have been fixed, enter the following command from the Terminal:
java Problem2 -
Make sure that the tests produce the expected results, and edit your methods as needed.
-
Once you are happy with your methods, put them in your
ps1_partI file. Do not submit the Problem2Test.java file.
Problem 3: Recursion and the runtime stack
12 points
Consider the following recursive method:
public static int mystery(int a, int b) {
if (a * b == 0) {
return a;
} else {
int myst_rest = mystery(a - 1, b - 2);
return b + myst_rest;
}
}
-
(5 points) Trace the execution of
mystery(5, 6). To do so, complete the template that we have provided in section 3-1 ofps1_partI. In particular, you should:-
Include a separate “frame” for each call. We have filled in some of the components of the frames for the first two calls for you. You should replace each
...with the appropriate integer, and you should add frames for additional calls as needed, until you reach the base case. -
Begin each frame with lines that explicitly state the values assigned to the parameters, as we have done for the first call.
-
Next, if the call is a base case, you can simply show the value that is returned (omitting the line for
myst_rest). If the call is a recursive case, you should show the recursive call on the line for myst_rest. -
Once you have reached the base case, you should work your way back through the frames for the previous calls. Add in both the results of the recursive call (i.e, the value assigned to
myst_rest) and the value returned by the call itself.
-
-
(2 points) What is the value returned by
mystery(5, 6)? -
(2 points) During the execution of
mystery(5, 6), method frames are added and then removed from the stack. How many method frames are on the stack when the base case is reached? You should assume that the initial call tomystery(5, 6)is made from within themain()method, and you should include the stack frame for main in your count. -
(3 points) Give an example of values of
aandbthat would produce infinite recursion, and explain why it would occur.
Problem 4: Rewriting a method
10 points
Consider the following method, which uses iteration (a for loop) to
search for an item in an array of integers. The method returns true if
the item is found in the array, and false if it is not.
public static boolean search(int item, int[] arr) {
for (int i = 0; i< arr.length; i++) {
if (arr[i] == item) {
return true;
}
}
return false;
}
-
(4 points) Rewrite this method so that it searches for an item in an array that can contain any type of object. Change the types of the parameters accordingly, and make whatever changes are needed to the body of the method.
-
(6 points) Rewrite your answer to part 1 so that it uses recursion instead of iteration. You will need to add a third parameter (call it
start) that keeps track of where you are in the array. More precisely,startwill specify the position in the array where the search for item should begin. For example,search("hello", arr, 0)should search for “hello” in the full array (beginning at position0), whereassearch("hello", arr, 2)should search for"hello"in the subarray that begins at position2and goes to the end of the array.
Submitting your work for Part I
Submit your ps1_partI.pdf file by taking the following steps:
-
If you still need to create a PDF file, open your file on Google Drive, choose File->Download->PDF document, and save the PDF file on your machine.
-
Click on the name of the assignment in the list of assignments on Gradescope. You should see a pop-up window labeled Submit Assignment. (If you don’t see it, click the Submit or Resubmit button at the bottom of the page.)
-
Choose the Submit PDF option, and then click the Select PDF button and find the PDF file that you created. Then click the Upload PDF button.
-
You should see a question outline along with thumbnails of the pages from your uploaded PDF. For each question in the outline:
- Click the title of the question.
- Click the page(s) on which your work for that question can be found.
As you do so, click on the magnifying glass icon for each page and doublecheck that the pages that you see contain the work that you want us to grade.
-
Once you have assigned pages to all of the problems in the question outline, click the Submit button in the lower-right corner of the window. You should see a box saying that your submission was successful.
Important
-
It is your responsibility to ensure that the correct version of every file is on Gradescope before the final deadline. We will not accept any file after the submission window for a given assignment has closed, so please check your submissions carefully using the steps outlined above.
-
If you are unable to access Gradescope and there is enough time to do so, wait an hour or two and then try again. If you are unable to submit and it is close to the deadline, email your homework before the deadline to
cscie22-staff@lists.fas.harvard.edu
Part II: Programming problems
60-70 points total
Problem 5: Adding methods to the ArrayBag class
25 points total
Getting started
-
If you haven’t already done so, create a folder named
ps1for your work on this assignment. -
Download the following file:
ArrayBag.javaMake sure to put the file in your
ps1folder. If your browser doesn’t allow you to specify where the file should be saved, try right-clicking on the link above and choosing Save as… or Save link as…, which should produce a dialog box that allows you to choose the correct folder for the file. -
In VSCodium, select the File->Open Folder menu option, and use the resulting dialog box to find and open the folder that you created for this assignment. (Note: You must open the folder; it is not sufficient to simply open the file.)
The name of the folder should appear in the Explorer pane on the left-hand side of the VSCodium window, along with the name of the
ArrayBag.javafile that you downloaded above. -
Click on the name
ArrayBag.java, which will open an editor window for that file. -
In
ArrayBag.java, add the methods described below to theArrayBagclass, and then add code to themain()method to test these methods. You should not add any new fields to the class. -
In the Terminal, use
javacto compile your code andjavato run it, taking steps similar to the ones described at the end of Problem 2.We strongly recommend compiling and testing each new method as you add it, fixing any issues with one method before moving on to the next one.
Here are the methods you should add:
-
public int capacity()
This method should return the maximum number of items that theArrayBagis able to hold. This value does not depend on the number of items that are currently in theArrayBag— it is the same as the maximum size specified when theArrayBagwas created. -
public boolean isFull()
This method should returntrueif the calledArrayBagis full, andfalseotherwise. -
public void increaseCapacity(int amount)
This method should increase the maximum capacity of the calledArrayBagby the specifiedamount. For example, ifbhas a maximum capacity of10, thenb.increaseCapacity(5)should giveba maximum capacity of15. As part of your implementation, you will need to create a new array with room to support the new maximum capacity, copy any existing items into that array, and replace the original array with the new one by storing its reference in the called object.Special cases:
-
If the parameter is
0, the method should just return without making any changes to the called object. -
If the parameter is negative, the method should throw an
IllegalArgumentException. See our secondArrayBagconstructor for an example of throwing an exception.
-
-
public boolean removeItems(ArrayBag other)
This method should attempt to remove from the calledArrayBagall occurrences of the items found in the parameterother. If the called object contains multiple copies of an item from otherBag, all of the copies should be removed. The method should returntrueif one or more items are removed andfalseotherwise.Hints:
-
Don’t forget that your
removeItemsmethod has direct access to the private fields of theArrayBagpassed in forother. See ourcontainsAllmethod for another example of anArrayBagmethod that takes anotherArrayBagobject as a parameter. -
You can simplify your implementation of this method if you have it call one or more of the existing methods of the
ArrayBagclass. Here again, the existingcontainsAllmethod provides a relevant example.
Special cases:
- The method should return
trueif the bag represented byotheris empty. - If the parameter is
null, the method should throw anIllegalArgumentException. See our secondArrayBagconstructor for an example of throwing an exception.
-
-
public ArrayBag unionWith(ArrayBag other)
This method should create and return anArrayBagcontaining one occurrence of any item that is found in either the called object or the parameterother. For full credit, the resulting bag should not include any duplicates. For example, ifb1represents the bag{2, 2, 3, 5, 7, 7, 7, 8}andb2represents the bag{2, 3, 4, 5, 5, 6, 7}, thenb1.unionWith(b2)should return anArrayBagrepresenting the bag{2, 3, 4, 5, 6, 7, 8}. Give the newArrayBaga maximum size that is the sum of the two bag’s maximum sizes.The hints for the previous method also apply here.
Special cases:
-
If one of the bags is empty, the method should return an
ArrayBagcontaining one occurrence of each item in the non-empty bag. -
If both of the bags are empty, the method should return an empty
ArrayBag. -
If the parameter is
null, the method should throw anIllegalArgumentException.
-
Problem 6: Recursion and strings
10-20 points total; 5 points each part
Getting started
-
In VSCodium, select the File->Open Folder menu option, and use the resulting dialog box to find and open your
ps1folder. The name of the folder should appear in a new Explorer pane on the left-hand side of the VSCodium window. -
Select File->New Text File, which will open up an empty window known as an editor window for your new program. It will initially have a name that is something like Untitled-1.
-
Select File->Save, and give the file the following name:
StringRecursion.javaImportant: When naming a Java file, the case of the letters matters. Make sure to use the exact combination of upper-case and lower-case letters that we have specified.
-
In your
StringRecursion.javafile, create a class namedStringRecursion, implement the methods described below within that class, and then create amain()method to test these methods. -
In the Terminal, use
javacto compile your code andjavato run it, taking steps similar to the ones described at the end of Problem 2.Here again, we recommend compiling and testing each new method before moving on to the next one.
Requirements:
- The methods that you write must be purely recursive. The use of iteration (i.e.,
for,while, ordo-whileloops) is not allowed. - The only built-in
Stringmethods that you may use arecharAt,length,equals, andsubstring. No use of otherStringmethods is allowed. In addition, make sure to follow any additional restrictions specified in the problem. - Do not use any global variables — i.e., variables that are declared outside of a method.
- Use the headers specified for the methods without changing them in any way.
- Limit yourself to writing the methods specified below. Do not write any additional “helper” methods that assist the required methods; rather, the methods listed below should provide all of their required functionality by themselves.
Here are the methods:
-
public static void printLetters(String str)
This method should use recursion to print the individual characters in the stringstr, separated by commas. All characters in the string should be printed, not just the letters. For example,printLetters("Rabbit")should printR, a, b, b, i, tand
printLetters("I like to recurse!")should printI, , l, i, k, e, , t, o, , r, e, c, u, r, s, e, !Note that there is a single space between each comma and the subsequent character. The method should not do any printing if the empty string (
"") or the valuenullis passed in as the parameter; it should simply return. -
public static String replace(String str, char oldChar, char newChar)
This method should use recursion to return aStringthat is formed by replacing all occurrences of the characteroldCharin the stringstrwith the characternewChar. For example:replace("base case", 'e', 'y')should return"basy casy"replace("base case", 'r', 'y')should return"base case"
This method should not do any printing; it should simply return the resulting string.
Special cases:
-
If the first parameter is
null, the method should returnnull. -
If the first parameter is the empty string (
""), the method should return the empty string.
-
(required for grad-credit students; “partial” extra credit for others)
public static int indexOf(char ch, String str)
This method should use recursion to find and return the index of the first occurrence of the characterchin the stringstr, or -1 ifchdoes not occur instr. For example:indexOf('b', "Rabbit")should return 2indexOf('P', "Rabbit")should return -1
The method should return -1 if the empty string (
"") or the valuenullis passed in as the second parameter. TheStringclass comes with a built-inindexOf()method; you may not use that method in your solution! -
(required for grad-credit students; “partial” extra credit for others)
public static String trim(String str)
This method should take a stringstrand use recursion to return a string in which any leading and/or trailing spaces in the original string are removed. For example:trim(" hello world ")should return the string"hello world"trim("recursion ")should return the string"recursion"
The
Stringclass comes with a built-intrim()method that does the same thing as the method that we’re asking you to write; you may not use that method in your solution!Special cases:
-
If the parameter is
null, the method should returnnull. -
If the parameter is the empty string, the method should return the empty string.
Problem 7: A Sudoku solver
25 points
In this problem, you will write a program that solves Sudoku puzzles using recursive backtracking.
Overview
A Sudoku puzzle consists of a 9x9 grid in which some of the cells have been filled with integers from the range 1-9. To solve the puzzle, you fill in the remaining cells with integers from the same range, such that each number appears exactly once in each row, column, and 3x3 subgrid.
Here is an example of an initial puzzle:

and here is its solution:

Getting started
Begin by downloading the following zip file: problem7.zip
Unzip this archive, and you should find a folder named problem7 that
contains all of the files that you need for this problem.
You should not move any of the files out of the problem7 folder.
Keep all of the files in the problem7 folder, and open that folder in
VSCodium using the File->Open Folder menu option.
Most of the functionality of your program should go in a class called
Puzzle, which you will use to represent an individual Sudoku puzzle.
We have provided you with skeleton code for this class in the file
Puzzle.java. The provided code includes:
-
a field called
valuesthat refers to a two-dimensional array of integers. This array is used to store the current contents of the cells of the puzzle, such thatvalues[r][c]stores the current value in the cell at rowr, columncof the puzzle. A value of0is used to indicate a blank cell. -
a field called
valIsFixedthat refers to a two-dimensional array of booleans. It is used to record whether the value in a given cell is fixed (i.e., part of the original puzzle).valIsFixed[r][c]istrueif the value in the cell at rowr, columncis fixed, andvalIsFixed[r][c]isfalseif the value in that cell is not fixed. For example, in the original puzzle above, there is a fixed4in the cell at row0, column1(the second cell in the top row), and thusvalIsFixed[0][1]would betruefor that puzzle. -
a field called
subgridHasValuethat refers to a three-dimensional array of booleans. This array allow us to determine if a given 3x3 subgrid of the puzzle already contains a given value. For example,subgridHasValue[0][0][4]will be true if the 3x3 subgrid in the upper left-hand corner of the board (a subgrid that we are identifying using the indices[0][0]) already has a4in one of its cells. See the comments accompanying this field for more information about the numbering of the subgrids. -
partial implementations of methods called
placeValue()andremoveValue()that place a value in a given cell and remove a value from a given cell by updating the fields mentioned above. You will need to add code to these methods to update the other fields that you add. -
a full implementation of a method called
readFrom()that takes aScanneras its only parameter and reads in a specification of a puzzle from thatScanner. This method assumes that a puzzle specification consists of nine lines of text — one for each row of the puzzle — and that each line contains nine digits separated by whitespace. Here again, 0 is used to indicate a blank cell. For example, the specification of the initial puzzle above would begin:0 4 0 0 0 3 7 0 0 0 8 9 7 0 0 1 0 0 ...The method reads in the puzzle specification and makes the corresponding changes to the fields mentioned above. You should not need to change this method, because it calls
placeValue(), and you are already modifying that method as needed. However, we do recommend that you read this method over. -
the full implementation of a method called
display()that prints out the current state of thePuzzleobject on which it is invoked. -
the skeleton of a private method called
solveRB()that you will implement. This is the recursive-backtracking method, and it should returntrueif a solution to the puzzle is found andfalseif no solution has been found (i.e., if the method is backtracking). If the initial call to this method returnsfalse, that means that no solution can be found — i.e., that the initial puzzle is not valid. If there is more than one solution (which can happen if the initial puzzle does not have enough numbers specified), your code should stop after finding one of them.Each invocation of the
solveRB()method is responsible for finding the value of a single cell of the puzzle. The method takes a parametern, which is the number of the cell that the current invocation of this method is responsible for. We recommend that you consider the cells one row at a time, from top to bottom and left to right, which means that they would be numbered as follows:0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... -
the full implementation of a public “wrapper” method called
solve()that makes the initial call tosolveRB(), and that returns the same value thatsolveRB()returns. -
a partial implementation of a constructor. You will need to add code to initialize the fields that you add.
We are also providing:
-
a separate
Sudokuclass in the fileSudoku.java. It contains themain()method for your Sudoku solver. You shouldn’t need to change this method (or any other code in this file), but we encourage you to review its use of the methods of thePuzzleclass. In particular, note that it displays the puzzle after the solution is found, and thus your recursive-backtracking method should not display it. -
a collection of four sample puzzle files:
- two puzzles with only one solution (
puzzle1.txtandpuzzle2.txt) no_solution.txt, which has no solutionmulti_sol.txt, which has multiple solutions.
Your task
Complete the Puzzle class in the ways described above so that
it can be used to solve Sudoku puzzles using recursive backtracking.
In addition to completing the methods mentioned above, you should also
add to the Puzzle class whatever additional fields or methods that
are needed to efficiently maintain the state of a Sudoku puzzle and to
solve it using recursive backtracking. In particular, we recommend
adding two fields:
-
one to keep track of whether a given row already contains a given value
-
one to keep track of whether a given column already contains a given value.
For full credit, you must use your additional fields and methods to avoid iterating over the Sudoku board unnecessarily.
Additional hints and suggestions
-
Take advantage of the first template in the notes for recursive backtracking — the one in which only one solution is found.
-
As mentioned above, the recursive
solveRB()method takes a single parameternthat represents the number of the cell that the current invocation is responsible for. You should usento compute the row and column indices of the current cell as follows:int row = n / DIM; int col = n % DIM;where
DIMis the class constant that we’ve provided for the dimension of the puzzle. -
We highly recommend that you add a non-static method that you can use to check the constraints of the puzzle before you attempt to assign a value to a given cell. This method will be similar to the
isSafemethod from the n-Queens code that we discussed in lecture. -
Make sure that you take advantage of the
subgridHasValuefield — along with the fields that you will add to keep track of the values in a given row and a given column of the puzzle — when deciding whether a particular value can be assigned to a particular cell. You should not scan through the puzzle to determine if a given value is valid. See the notes for n-Queens for another example of efficient constraint checking. -
Make sure that you use the
addValue()andremoveValue()methods when updating the state of the puzzle, and that you add code to these methods as needed to update the fields that you add to thePuzzleclass. -
Make sure that you don’t attempt to assign a new number to cells that are filled in the original puzzle — i.e., cells whose values are fixed. Your
solveRB()method will need to skip over these cells somehow.
Testing your code
Use the provided sample puzzles to test your code.
For example, here’s what you should see if you use the program to
solve the puzzle found in puzzle1.txt:
Please enter the name of puzzle file: puzzle1.txt
Here is the initial puzzle:
-------------------------------------
| | 4 | | | | 3 | 7 | | |
-------------------------------------
| | 8 | 9 | 7 | | | 1 | | |
-------------------------------------
| | | | | | 4 | 2 | | |
-------------------------------------
| | | | | | | | | 1 |
-------------------------------------
| 6 | | | 5 | 1 | 8 | | | 9 |
-------------------------------------
| 2 | | | | | | | | |
-------------------------------------
| | | 5 | 3 | | | | | |
-------------------------------------
| | | 6 | | | 1 | 9 | 4 | |
-------------------------------------
| | | 1 | 2 | | | | 6 | |
-------------------------------------
Here is the solution:
-------------------------------------
| 1 | 4 | 2 | 9 | 8 | 3 | 7 | 5 | 6 |
-------------------------------------
| 5 | 8 | 9 | 7 | 2 | 6 | 1 | 3 | 4 |
-------------------------------------
| 7 | 6 | 3 | 1 | 5 | 4 | 2 | 9 | 8 |
-------------------------------------
| 9 | 5 | 8 | 4 | 3 | 2 | 6 | 7 | 1 |
-------------------------------------
| 6 | 3 | 7 | 5 | 1 | 8 | 4 | 2 | 9 |
-------------------------------------
| 2 | 1 | 4 | 6 | 9 | 7 | 5 | 8 | 3 |
-------------------------------------
| 4 | 7 | 5 | 3 | 6 | 9 | 8 | 1 | 2 |
-------------------------------------
| 3 | 2 | 6 | 8 | 7 | 1 | 9 | 4 | 5 |
-------------------------------------
| 8 | 9 | 1 | 2 | 4 | 5 | 3 | 6 | 7 |
-------------------------------------
If your code isn’t working, see the PS 1 FAQ for suggestions of steps you can take to debug it.
Submitting your work for Part II
You should submit the following files:
ArrayBag.javaStringRecursion.javaPuzzle.java
Here are the steps:
-
Click on the name of the assignment in the list of assignments. You should see a pop-up window with a box labeled DRAG & DROP. (If you don’t see it, click the Submit or Resubmit button at the bottom of the page.)
-
Add all three files to the box labeled DRAG & DROP. You can either drag and drop the files from their folder into the box, or you can click on the box itself and browse for the files.
-
Click the Upload button.
-
You should see a box saying that your submission was successful. Click the
(x)button to close that box. -
The Autograder will perform some tests on your file. Once it is done, check the results to ensure that the tests were passed. If one or more of the tests did not pass, the name of that test will be in red, and there should be a message describing the failure. Based on those messages, make any necessary changes. Feel free to ask a staff member for help.
Note: You will not see a complete Autograder score when you submit. That is because additional tests will be run later, after the final deadline for the submission has passed. For such problems, it is important to realize that passing all of the initial tests does not necessarily mean that you will ultimately get full credit on the problem. You should always run your own tests to convince yourself that the logic of your solutions is correct.
-
If needed, use the Resubmit button at the bottom of the page to resubmit your work. Important: Every time that you make a submission, you should submit all of the files for that Gradescope assignment, even if some of them have not changed since your last submission.
-
Near the top of the page, click on the box labeled Code. Then click on the name of each file to view its contents. Check to make sure that you see the code that you want us to grade.
Important
-
It is your responsibility to ensure that the correct version of every file is on Gradescope before the final deadline. We will not accept any file after the submission window for a given assignment has closed, so please check your submissions carefully using the steps outlined above.
-
If you are unable to access Gradescope and there is enough time to do so, wait an hour or two and then try again. If you are unable to submit and it is close to the deadline, email your homework before the deadline to
cscie22-staff@lists.fas.harvard.edu