Problem Set 1: C
tl;dr
-
Watch Week 1’s lecture.
-
Say hello to the world 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.
Help
For help with Week 1 and Problem Set 1:
-
Watch Zamyla’s walkthroughs herein.
-
Start a discussion with classmates.
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, selecting edX from the drop-down menu when prompted.
If you typically sign into edX via Facebook, Google, or Microsoft, you’ll first need to create a password for your edX account as follows:
|
Upon logging into CS50 IDE for the first time, 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
Step 1 of 3
Recall that you were asked to create the files below:
-
hello.c
-
water.c
-
mario.c
-
greedy.c
orcredit.c
Be sure that each of your files is in ~/workspace/pset1
, as with:
cd ~/workspace/pset1/
ls
If any file is not in ~/workspace/pset1/
, move it into that directory, as via mv
(or via CS50 IDE’s lefthand file browser).
Step 2 of 3
-
To submit
hello
, executecd ~/workspace/pset1/ submit50 cs50/2017/x/hello
inputting your GitHub username and GitHub password as prompted.
-
To submit
water
, executecd ~/workspace/pset1/ submit50 cs50/2017/x/water
inputting your GitHub username and GitHub password as prompted.
-
To submit the less-comfortable version of
mario
(if you implemented it), executecd ~/workspace/pset1/ submit50 cs50/2017/x/mario/less
inputting your GitHub username and GitHub password as prompted.
-
To submit the more-comfortable version of
mario
(if you implemented it), executecd ~/workspace/pset1/ submit50 cs50/2017/x/mario/more
inputting your GitHub username and GitHub password as prompted.
-
To submit
greedy
(if you implemented it), executecd ~/workspace/pset1/ submit50 cs50/2017/x/greedy
inputting your GitHub username and GitHub password as prompted.
-
To submit
credit
(if you implemented it), executecd ~/workspace/pset1/ submit50 cs50/2017/x/credit
inputting your GitHub username and GitHub password as prompted.
If you run into any trouble, email sysadmins@cs50.harvard.edu!
You may resubmit any problem as many times as you’d like.
Step 3 of 3
Submit this form!
Your submission should be graded within 2 minutes, at which point your score will appear at cs50.me!
This was Problem Set 1.