Exercise 10: Transpose, Palindrome, Rotate, Marnell, Bracket
PE2 AY18/19 Semester 1
Deadline
This is an ungraded exercise.
Prerequisite
- You are able to access the CS1010 programming environment.
- You are familiar with basic UNIX CLI and using terminal-based editor
vim
. - You have gone through Exercise 0 and have already set up your
.gitconfig
. - You are familiar with the steps of accepting, downloading, and submitting your exercise and assignment.
- You are familiar with the directory structure and the common files included in your assignment skeleton.
- You are comfortable writing simple C programs that involve arithmetic operations,
long
,double
, andbool
types, conditionalif
/else
statements, and loops. - You are comfortable writing C programs that involve 1D and multi-dimension arrays
- You are comfortable breaking down a problem into smaller sub-problems which can be resolved using functions, including reusing existing functions written for other programs (with a tweak), writing a function that calls itself, designing what should the inputs and return values/types of a function.
- You are able to write C programs that are neat and readable, adhering to a common prescribed coding convention.
- You are familiar with the principles behind binary search and common O(n^2) sorting algorithms.
- You are familiar with solving problems recursively.
Setup
- First, accept the assignment on GitHub
- Then, log in to one of the hosts of CS1010 programming environment and run
1 |
|
- You should see the folder
ex10-<github username>
in your home directory with the assignment skeleton inside. - Inside that directory, you should see the following files:
transpose.c
,palindrome.c
,rotate.c
,marnell.c
andbracket.c
are the most important files. They are the skeleton C code that you should edit to solve the assignment and the only files that you should change.inputs
andoutputs
are subdirectories that contain test inputs and test outputs. We use the same convention as Exercise 0 so you should already be familiar with them.Makefile
: This is the configuration for the toolmake
that we use to automate the compilation and testing of the programs.test.sh
: This is a bash script for testing your code.compile_flags.txt
: This file specifies the flags for compilation and is used by bothmake
andclang-tidy
.Questions.md
containing the description of the questions. This is a plain text file that you can view withvim
,less
, or other tools.
Solving The Assignments
- Edit the files
transpose.c
,palindrome.c
,rotate.c
,marnell.c
andbracket.c
to solve the corresponding question as described inQuestions.md
. -
To compile and run tests with the sample inputs and outputs:
This command will compile all your C files with the appropriate settings and if there is no error, run the test scripts. If you pass the test cases, it will run1
make
clang-tidy
to check if your code follows good code practices. -
The test cases are given in the
inputs
andoutputs
subdirectory. You can usecat
orless
to look at the content of these test cases. You can add more test cases or edit the given ones if needed. -
To compile individual program, type
For instance, the command1
make <program>
compiles1
make transpose
transpose.c
intoecho
without testing or runningclang-tidy
on it. -
To test individial program, run
1
./test.sh <program>
For instance, the command
tests1
./test.sh transpose
transpose
without compiling or runningclang-tidy
onecho.c
.
Submission
When you are ready, run the following command to submit:
1 |
|
The files transpose.c
, palindrome.c
, rotate.c
, marnell.c
, and bracket.c
will be uploaded to GitHub. You can submit multiple times, but only the last submission will be graded.
Manipulating Files on GitHub
Do not manipulate (e.g., edit) the files on GitHub or close the pull requests on GitHub. Doing so would interfere with the scripts and the grading/testing process of CS1010.
Identifying Yourself
In every C file that you submit to CS1010, you need to identify yourself by writing your name and tutorial group. Marks will be deducted if you fail to do so. You need to edit the line:
1 |
|
and change it to something like:
1 |
|
Questions
To acclimatize you to the PE condition, the questions for this assignment is included in the skeleton instead, in a file named Questions.md
.
You should learn how to use vim
to open both the .c
file and Questions.md
side-by-side (see https://nus-cs1010.github.io/2122-s1/vim.html#splitting-vims-viewport)