part I due by 10:00 p.m. on Wednesday, June 25, 2025
part II due by 10:00 p.m. on Thursday, June 26, 2025
In your work on this assignment, make sure to abide by the policies on academic conduct.
Problem Set 0
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
cscis111-staff@lists.fas.harvard.edu
.
Make sure to submit your work on Gradescope, following the procedures found at the end of Part I and Part II.
35 points total
If you haven’t already created a folder named s111
for your
work in this course, follow these
instructions to do so.
Then create a subfolder called ps1
within your s111
folder,
and put all of the files for this assignment in that folder.
The problems from Part I will all be completed in a single plain-text 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 ps1
folder. The resulting file (ps1_partI.pdf
) is the one that
you will submit. See the submission guidelines at the end of Part I.
7 points; pair-optional
This is one of only two problems from this assignment that you may complete with a partner. See the rules for working with a partner on pair-optional problems for details about how this type of collaboration must be structured.
Develop a set of rules that cause Picobot to completely cover an empty square room, regardless of where it starts within the room.
You may find it helpful to review the material on Picobot in the lecture notes.
Open the Picobot simulator, and modify/replace the existing rules with your own rules until you can get it to work. Whenever you modify the rules, be sure to click the Enter rules for Picobot button before you click Go.
As discussed in lecture, you cannot include repeat rules – two or more rules that would both be triggered by a given combination of state and surroundings.
When you are satisfied with your rules, copy them into the
ps1_partI
file that you created following the guidelines above.
We encourage you to include comments that describe your rules. These
comments should be preceded by a #
symbol. For example:
# The following rule tells Picobot to ...
Hints:
One possible approach is to begin with the four rules that are present in Picobot when you first load it in your browser. Try those rules on several different starting positions by repeatedly clicking the Reset button and then the Go button.
Ask yourself: What portion of the overall task do these initial rules accomplish? What remains to be done? Then try to add rules that will cause the robot to move in ways that will complete the overall task of covering/vacuuming the entire room. You will also need to revise the second rule so that it doesn’t cause the robot to crash when it has a wall to its west.
It’s worth noting that it’s perfectly okay if your new rules cause the robot to revisit portions of the room that it has already covered. More generally, your rules do not need to be efficient!
for personal gratification only!
At the heart of computer science are questions of complexity and
efficiency: questions about how simple, fast, etc. the solution to a
problem can be. For an optional challenge, see if you can create a
solution for problem 1 that uses only 6 rules! If you are able to do so,
include them in the separate section provided in ps1_partI
.
Note: Because reducing the number of rules to 6 is a completely optional challenge, we will not be answering questions about how to do so!
13 points; pair-optional
This is one of only two problems from this assignment that you may complete with a partner. See the rules for working with a partner on pair-optional problems for details about how this type of collaboration must be structured.
Develop a set of rules that enable Picobot to completely navigate
a connected maze with corridors one square wide, regardless of its
starting point. You can obtain an example of such a maze by opening
the Picobot simulator and clicking on the right-arrow (-->
)
button below the lower right-hand corner of the room, which will show
you this maze:
Modify/replace the existing rules with your own rules until you can get it to work. Whenever you modify the rules, be sure to click the Enter rules for Picobot button before you click Go.
As discussed in lecture, you cannot include repeat rules – two or more rules that would both be triggered by a given combination of state and surroundings.
When you are satisfied with your rules, copy them into your
ps1_partI
file. We encourage you to include comments that describe
your rules. These comments should be preceded by a #
symbol, as
described in the earlier problem.
Hint: We strongly recommend that you take the approach outlined in lecture, which involves:
for personal gratification only!
See you if you can create a solution for problem 2 that uses only 8 rules.
This is extremely challenging, and we don’t recommend starting with
only 8 rules! Rather, begin by having at least 3 rules for each state
as discussed in lecture, and then see if you combine rules
in some way. If you are able to come up with a set of 8 rules that works,
include them in the separate section provided in ps1_partI
.
Note: Because reducing the number of rules to 8 is a completely optional challenge, we will not be answering questions about how to do so!
9 points; individual-only
As discussed in lecture, there are a number of basic rules that all Java programs must follow. These rules are part of the syntax of the language. The following Java program violates several of these rules:
public class BuggyProgram { public void main(String[]) System.out.println("Help! This program is buggy.) System.out.println("Please find and fix the bugs.") } }
Determine and fix all of the problems with this program. You may find it helpful to test your revised program in VS Code by entering it in the text editor and seeing if it compiles and runs. If you do this, remember that you will need to give the program file an appropriate name that is based on the name of the class.
Once you are confident that you have fixed all of the problems
in the code, put the revised program in your ps1_partI
file as your answer to this question.
Class and method names must be valid Java identifiers. Which of the following names are not valid identifiers?
airForce1 static second Option mainStreet first_name 3muskateers
Explain your answer briefly.
What series of println
statements would produce the following
output? Make sure to include any escape characters that are
needed within the string literals.
"You're in.", Heidi told one of the designers. She continued, "And that means you're out." -----\\\\\/////-----
6 points; individual-only
What is the output of the following program? (Try to determine the answer before you actually run the program!)
public class Flow { public static void A() { C(); System.out.println("scratch"); } public static void B() { System.out.println("meow!"); A(); } public static void C() { System.out.println("cat"); } public static void D() { C(); A(); } public static void main(String[] args) { A(); B(); D(); } }
Submit your ps1_partI.txt
file by taking the following steps:
Login to Gradescope by clicking the link in the left-hand navigation bar.
Click on the box for CSCI S-111.
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 in your ps1
folder.
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:
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
cscis111-staff@lists.fas.harvard.edu
30 points total
30 points; individual-only
In this problem, you will write a program that tests your
understanding of Java program structure, println
statements, static
methods, and procedural decomposition. You should limit yourself to
the aspects of Java that are covered in Unit 1 of the coursepack, even
if you are already aware of other programming constructs that could be
useful. You may find it helpful to consult the example
programs.
Your task is to display the phrase GOING GOING GONE
using block
letters that are created by sequences of println
statements. The
letters should be displayed vertically as follows:
+------ | | | --+ | | | | +-----+ +-----+ | | | | | | | | | | +-----+ ---+--- | | | | | ---+--- | | |\ | | \ | | \ | | \ | | \| | | +------ | | | --+ | | | | +-----+ +------ | | | --+ | | | | +-----+ +-----+ | | | | | | | | | | +-----+ ---+--- | | | | | ---+--- | | |\ | | \ | | \ | | \ | | \| | | +------ | | | --+ | | | | +-----+ +------ | | | --+ | | | | +-----+ +-----+ | | | | | | | | | | +-----+ | | |\ | | \ | | \ | | \ | | \| | | +------ | | +------ | | +------
If you haven’t already done so, create a folder named ps1
for your work on this assignment. You can find instructions for
doing so here.
In VS Code, select the File->Open Folder or File->Open menu
option, and use the resulting dialog box to find and open your
ps1
folder. The name of the folder should appear in a new
Explorer pane on the left-hand side of the VS Code 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:
BlockLetterWriter.java
Important: 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.
Correctness
The output of your program should exactly match the output shown
above. In particular:
GOING
).GOING
and GONE
).-
).|
) character, which is found above the
Enter or Return key on most keyboards. (Note: On some browsers,
the vertical bar characters shown above will blend together into a
single vertical line, but in VS Code there should be breaks visible
between the vertical bars.)There should be no spaces at the end of any of the string literals that you print, and there should be no unnecessary spaces at the beginning of a string literal. For example, the string literal used to print the second line of a block letter I should be
" |"
– i.e., exactly three spaces, followed by a vertical bar character, with no spaces after the vertical bar.
A text file with the expected output is available here.
Procedural decomposition
In order to receive full credit, your solution must use
procedural decomposition — breaking the larger problem of
displaying the phrase GOING GOING GONE
into subproblems, and using
static methods to solve the subproblems. More specifically, you
should use static methods:
to capture the structure of the solution. For example, you should have a separate method for each letter in the phrase. However, having a separate method for each letter alone is not enough. Rather, you should also come up with other ways in which a method would help you to capture structure.
to eliminate code duplication. Typically, you wouldn’t create a
method to avoid repeating just one or two println
statements.
However, if a specific group of four or more println
statements
is repeated, you should create a separate method for
those four or more statements.
Don’t forget that methods can call other methods as needed.
Other requirements
BlockLetterWriter
, which
means that you will need to store it in a file named
BlockLetterWriter.java
.Submit your BlockLetterWriter.java
file by taking the following steps:
Login to Gradescope by clicking the link in the left-hand navigation bar.
Click on the box for CSCI S-111.
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 your file to the box labeled DRAG & DROP. You can either drag and drop the file from its folder into the box, or you can click on the box itself and browse for the file.
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
cscis111-staff@lists.fas.harvard.edu
Last updated on June 24, 2025.