Homework 1
Last updated: Mon, 9 Sep 2024 19:29:37 -0400
Out: Mon Sep 09, 2024, 12pm (noon) EST
Due: Mon Sep 16, 2024, 12pm (noon) EST
Overview
In this homework, we will continue practicing programming in a functional style, using Racket.
Note: This assignment assumes you have completed Homework 0. You will not be able to complete this assignment until you have done Homework 0.
Since this course is about using language to communicate effectively, hws will be graded on more than just correctness, begining with this assignment. Specifically, this hw will be graded accordingly:
correctness (8 pts)
style (see below for details) (7 pts)
README (1 pt)
Total: 16 points
Setup
Create a new repository for this assignment by going to the CS450 Fall 2024 GitHub Organization and clicking "New".
Note: The CS450 Fall 2024 GitHub Organization must be the owner of the repository. Do not create the repository in your own account.
Name the repository hw<X>-<LASTNAME>-<FIRSTNAME> where <X> is the current homework number.
For example, I would name my hw1 repository hw1-Chang-Stephen.
Mark the repository as Private.
Check "Add a README file".
Select the Racket template for the .gitignore.
Choose whatever you wish for the license.
When done click "Create repository".
Tasks
Read Chapters 1.4-1.7 and 2.1-2.4 of the Textbook and do the exercises below.
NOTE: The textbook will refer to "Student Languages" which we will not use in this course (and a "Stepper" that only works with the Student Languages). Instead, we will always use the full Racket language, which is invoked by putting #lang racket at the top of a file (see also Before Submitting).
Put your code in a file named hw1.rkt.
All required defines should use the name specified in the exercise and should be provided.
You can see an example of what an initial hw1.rkt file looks at in hw1 starter code.
Define a function str-insert-underscore which takes a string and a (0-based) position i and inserts an underscore (_) character at position i.
Define a function str-delete-i which takes a string and a (0-based) position i returns a new string where the i-th character in the input string has been removed.
Define a function img-insert-circ which takes a 2htdp/image image and inserts a solid red circle with radius 10 in the middle of the image.
Since the circle to add is always the same, it should not be re-computed on every call of the function. Instead, define a constant named CIRC RED-CIRC (remember that constants should be in all caps, according to our course’s Style Guide) and use it in the function.
Define a function add-cherry-on-top that takes a 2htdp/image image and adds a red circle with radius 10 on top of the image, centered. You should re-use the same constant you defined in the previous question.
Define a function img-area which takes a 2htdp/image image returns a nonnegative-integer representing the area of the image in pixels.
Before Submitting
Testing
Do not submit until all code has been thoroughly tested (by you).
Assignments may or may not use a GradeScope Autograder, but either way, an Autograder is not a software development tool so do not use it as one. Code must be tested independent of any Autograder.
If you submit and get an Autograder error, this means the code you wrote is not complete and/or not correct and it’s up to you to figure out why.
Of course, the course staff is here and eager to help, but cannot do so if a student does not explain what they’ve tried first (e.g., "why is the Autograder giving an error?" is not something we can help with).
The Autograder test suite is subject to change. This means that the visible grade seen during submission is not the final grade.
Style
All code should follow proper Racket Style.
Also, the repository itself must follow proper style. Specifically, it must have appropriate commit messages. See How to Write a Git Commit Message if you are unsure how to write a commit message.
Files
A submission must have the following files in the repository root:
hw1.rkt: Contains the hw solution code.
All defines should use the name specified in the exercise (ask if you are unsure) and should be provided.
The easiest (but not always the most readable) way to ensure all necessary definitions are provided is to (initially) put as the second line in the file:
This automatically provides all definitions in the file. (The first line should be #lang racket)
README.md: Contains the required README information, including the GitHub repo url.
Submitting
When you are done, submit your work to Gradescope hw1. You must use the "GitHub" Submission Method and select your hw<X>-<LASTNAME>-<FIRSTNAME> repository.
Note that this is the only acceptable way to submit homework in this course. (Do not manually upload files and do not email files to the course staff. Homework submitted via any unapproved methods will not be graded.)