Skip to main content

Homework 2 — Time & Place: Functions and Conditionals

Skills: 1, 11

Due

Thursday, September 18, 2025 at 6PM (Oakland) or 9PM (Boston)


Introduction

Consider that we can use a number to represent seconds in a minute: any whole number from 0 to 59 (inclusive) is valid, but numbers above or below (or fractions or decimals) are not valid.

Problem 1

Design a function, tick, that takes a number of seconds and returns the next second, as if a clock were ticking. Be sure that it does the right thing if given 59 seconds is input! Be sure to include a doc: string and test cases in a where: block!

Problem 2

Design a function seconds-to-image that, given a number of seconds (a number between 0 and 59), produces an image of a timer with the seconds hand at the appropriate place -- i.e., an analog clock face with just a second hand. It's up to you how you would like it to look, but one way could be:

Timer image example

It's also not required for the hand to only extend from one side. i.e., it would be fine if your timer looked like this (for 15 & 45):

Timer image example

You do not need to provide any markings or numbers on the timer face, or to include test cases, but you should include a doc: string.

Problem 3

You're designing a conference registration system, and one component of that is taking registration data and using it to construct conference badges that will be printed out for attendees to wear.

Please implement the following function, which should create an image of a Badge. NOTE: you do not need to write test cases for this function, but please run it a few times in the interactions window to make sure the output looks good.

fun print-conference-badge(name :: String, gender :: String, email :: String, nuid :: String) -> Image:
doc: "prints a conference attendee badge"
# ...
end

Problem 4

According to the contextual integrity framework, privacy involves maintaining "appropriate flows of information in a particular context." Here is a filled-out analysis of the flows of badge information in the context of the conference:

What type of information is shared?Personal information: name, gender, email, NUID
Who is the subject of the information on each badge?The conference attendee wearing the badge
Who is the sender of the information?The conference organizers
Who are the potential recipients of the information?Intended recipients:
All conference attendees, sponsors, and co-organizers

Unintended recipients:
Other people in the building
Other people on the street if attendees forget to take off their badge
Other people who have access to the information database such as future conference organizers
What principles govern the collection and transmission of this information?Collection is mandatory for all conference attendees and they consent to giving us this information in order to attend.

The principle of data minimization suggests that we limit the collection, storage, and transmission of personal data to only the data absolutely necessary to perform the task.

Using our privacy analysis above, identify one of the four pieces of information that we currently collect (name, gender, email, NUID) that isn’t absolutely necessary to share with all of the potential recipients at a conference. Explain in 1-2 sentences why removing this piece of information from the badge would be beneficial to preserve privacy.

Problem 5

Create a new function, print-conference-badge-minimal, that reflects your decision in Problem 4, only accepting the necessary information and creating an image of a badge with it.