Problem Set 1: C
tl;dr
-
Watch Week 1’s lecture.
-
Get your CS50 IDE set up with
hello.c
. -
Calculate your water consumption with
water.c
. -
Recreate one of Mario’s pyramids, in
mario.c
. -
Provide a user with either cash or credit in
greedy.c
orcredit.c
. -
Submit your code.
-
Submit a form.
Getting Started
Recall that CS50 IDE is a web-based "integrated development environment" that allows you to program "in the cloud," without installing any software locally. Underneath the hood is a popular operating system, Ubuntu Linux, that’s been "containerized" with open-source software called Docker, that allows multiple users (like you!) to share the operating system’s "kernel" (its nucleus, so to speak) and files, even while having files of their own. Indeed, CS50 IDE provides you with your very own "workspace" (i.e., storage space) in which you can save your own files and folders (aka directories).
Logging In
Head to cs50.io and log into CS50 IDE. You may be prompted (again) for your email address. If so, after providing it, click Private under Hosted workspace, then click Create workspace.
You should then be informed that CS50 IDE (aka Cloud9, the software that underlies CS50 IDE) is "creating your workspace" and "creating your container," which might take a moment. You should eventually see your workspace, which should resemble mine from Week 1. If not, do just email the course’s heads to inquire!
Updating
Toward the bottom of CS50 IDE’s UI is a "terminal window" (light blue, by default), a command-line interface (CLI) that allows you to explore your workspace’s files and directories, compile code, run programs, and even install new software. You should find that its "prompt" resembles the below.
~/workspace/ $
Click inside of that terminal window and then type
update50
followed by Enter to ensure that your workspace is up-to-date. It might take a few minutes for any updates to complete. (Be sure not to close the tab or CS50 IDE itself until they do!)
Next, execute
mkdir ~/workspace/pset1/
at your prompt in order to make a directory called pset1
in your workspace
directory. Take care not to overlook the space between mkdir
and ~/workspace/pset1
or any other character for that matter! Keep in mind that ~
denotes your home directory, ~/workspace
denotes a directory called workspace
therein, and ~/workspace/pset1
denotes a directory called pset1
within ~/workspace
.
Now execute
cd ~/workspace/pset1/
to move yourself into (i.e., open) that directory. Your prompt should now resemble the below.
~/workspace/pset1/ $
If not, retrace your steps and see if you can determine where you went wrong. You can actually execute
history
at the prompt to see your last several commands in chronological order if you’d like to do some sleuthing. You can also scroll through the same one line at a time by hitting your keyboard’s up and down arrows; hit Enter to re-execute any command that you’d like.
How to Submit
For this and future problem sets, we’ll be using a submission system based on GitHub, a popular site for storing code. Recall that for Problem Set 0 you signed up (hopefully!) for an account on github.com. If you didn’t, please go fill out that form now; you won’t be able to submit without a GitHub account, and we’ll need to know your account name in order to give your teaching fellow access to grading it!
Step 2 of 5
Visit cs50.me and sign in using your GitHub credentials. This will authorize the submit50
utility to push your code to your GitHub repositories on your behalf so that your work can be commented on and graded by your teaching fellow.
Step 3 of 5
Return to your CS50 IDE and navigate to your terminal window. Begin by first executing:
cd ~/workspace/pset1
-
Then, to submit
hello
, executesubmit50 2017/spring/hello
inputting your GitHub username and GitHub password as prompted. You should be notified that
hello.c
will be submitted, but no other files in your~/workspace/pset1
directory will. This is to be expected; you’ll submit the other files using other submission commands in just a moment! -
To submit
water
, execute:submit50 2017/spring/water
-
To submit
mario
, execute:submit50 2017/spring/mario
-
To submit
greedy
(if you implemented it), execute:submit50 2017/spring/greedy
-
To submit
credit
(if you implemented it), execute:submit50 2017/spring/credit
If you run into any trouble, email sysadmins@cs50.harvard.edu, cc’ing heads@cs50.harvard.edu!
You may resubmit any problem as many times as you’d like, up until the problem set deadline.
Step 4 of 5
To confirm that your work was indeed submitted, you can either visit the links that are generated at the end of the submit50
output, or you can view all of your work in a centralized location at cs50.me.