Mario
Getting Started
Open VS Code.
Start by clicking inside your terminal window, then execute cd
by itself. You should find that its āpromptā resembles the below.
$
Click inside of that terminal window and then execute
wget https://cdn.cs50.net/2022/fall/psets/1/mario-more.zip
followed by Enter in order to download a ZIP called mario-more.zip
in your codespace. Take care not to overlook the space between wget
and the following URL, or any other character for that matter!
Now execute
unzip mario-more.zip
to create a folder called mario-more
. You no longer need the ZIP file, so you can execute
rm mario-more.zip
and respond with āyā followed by Enter at the prompt to remove the ZIP file you downloaded.
Now type
cd mario-more
followed by Enter to move yourself into (i.e., open) that directory. Your prompt should now resemble the below.
mario-more/ $
If all was successful, you should execute
ls
and see a file named mario.c
. Executing code mario.c
should open the file where you will type your code for this problem set. If not, retrace your steps and see if you can determine where you went wrong!
World 1-1
Toward the beginning of World 1-1 in Nintendoās Super Mario Brothers, Mario must hop over adjacent pyramids of blocks, per the below.
Letās recreate those pyramids in C, albeit in text, using hashes (#
) for bricks, a la the below. Each hash is a bit taller than it is wide, so the pyramids themselves will also be taller than they are wide.
# #
## ##
### ###
#### ####
The program weāll write will be called mario
. And letās allow the user to decide just how tall the pyramids should be by first prompting them for a positive integer between, say, 1 and 8, inclusive.
Hereās how the program might work if the user inputs 8
when prompted:
$ ./mario
Height: 8
# #
## ##
### ###
#### ####
##### #####
###### ######
####### #######
######## ########
Hereās how the program might work if the user inputs 4
when prompted:
$ ./mario
Height: 4
# #
## ##
### ###
#### ####
Hereās how the program might work if the user inputs 2
when prompted:
$ ./mario
Height: 2
# #
## ##
And hereās how the program might work if the user inputs 1
when prompted:
$ ./mario
Height: 1
# #
If the user doesnāt, in fact, input a positive integer between 1 and 8, inclusive, when prompted, the program should re-prompt the user until they cooperate:
$ ./mario
Height: -1
Height: 0
Height: 42
Height: 50
Height: 4
# #
## ##
### ###
#### ####
Notice that width of the āgapā between adjacent pyramids is equal to the width of two hashes, irrespective of the pyramidsā heights.
Open your mario.c
file to implement this problem as described!
Walkthrough
How to Test Your Code
Does your code work as prescribed when you input
-1
(or other negative numbers)?0
?1
through8
?9
or other positive numbers?- letters or words?
- no input at all, when you only hit Enter?
You can also execute the below to evaluate the correctness of your code using check50
. But be sure to compile and test it yourself as well!
check50 cs50/problems/2023/summer/mario/more
Execute the below to evaluate the style of your code using style50
.
style50 mario.c
How to Submit
Per Step 4 below, after you submit, be sure to check your autograder results. If you see SUBMISSION ERROR: missing files (0.0/1.0)
, it means your file was not named exactly as prescribed (or you uploaded it to the wrong problem).
Correctness in submissions entails everything from reading the specification, writing code that is compliant with it, and submitting files with the correct name. If you see this error, you should resubmit right away, making sure your submission is fully compliant with the specification. The staff will not adjust your filenames for you after the fact!
- Download your
mario.c
file by control-clicking or right-clicking on the file in your codespaceās file browser and choosing Download. - Go to CS50ās Gradescope page.
- Click āProblem Set 1: Mario (More)ā.
- Drag and drop your
mario.c
file to the area that says āDrag & Dropā. Be sure it has that exact filename! If you upload a file with a different name, the autograder likely will fail when trying to run it, and ensuring you have uploaded files with the correct filename is your responsibility! - Click āUploadā.
You should see a message that says āProblem Set 1: Mario (More) submitted successfully!ā
Donāt forget that, starting this week, problems will be graded along the axis of Design also, which is done manually by your TF after the submission deadline. The autograder only awards 7.5 of the 12.5 available points, and the other 5 will be awarded at the discretion of your TF when providing qualitative feedback.