You are on page 1of 3

CPS Assignment 1

Deadline: August 22, 2015

Instructions
1. Naming conventions are to be followed with extreme precision. A script
will automatically evaluate your programs. And any deviation from the
prescribed folder names, file names or function names results in that
folder/file/program/function being discarded/unrecognized. This will only
reward you with 0 marks (for that particular question).
2. Hope you have all created a bitbucket account as per the invitation sent
to you guys. You will notice a shared repo already under your username.
This is where your assignment has to be finally uploaded.
3. Firstly create your own local repo titled assignment-1. All your programs
shall be written within this repo.
4. Name each of your programs as per the question number. If the question
number is 1, then the program name should be 1.rkt.
5. Push the local assignment-1 repository to the shared bitbucket repository.
6. A set of practice questions shall also be uploaded soon (by tonight). These
practice questions are not going to be graded. However, they may help
you in solving the assignment problems.

Questions

This September commemorates the 24th anniversary of Harrys first train ride
to Hogwarts. Let us also begin your first ride into Scheme/racket similarly.
1. Write a function(WAF) wizardingTest that takes year of birth (YOB),
as input and returns as output:
OWLs if the age is 16
NEWTs if age is 18
Whats the hurry? if age is lesser that 16
Too old for school! if age is greater than 18
Confundus Charm? if age is not a natural number
Sample Run > (wizardingTest 1991)

Sample Output Too old for school!


Sample Run > (wizardingTest 2k)
Sample Output Confundus Charm?
Sample Run > (wizardingTest 1999)
Sample Output OWLs
2. There were 99 other students that joined Hogwarts along with Harry (in
1991). The number of students that enrolled rises by 1% each year. WAF
numStud that will take in a year (a natural number obviously) as input.
This function should calculate the number of students that may have
enrolled in that year.
Sample Run > (numStud 2K15)
Sample Output Confundus Charm?
Sample Run > (numStud 1990)
Sample Output 99 ; 99.00990099 rounded off to 99 (you cant have fractional number of
students)
3. Now lets do the reverse. WAF foundingYear which calls the same function numStud, that finds out when the school was started. Assume the
school started off with exactly 20 students.
This year (2015) also marks the 20th anniversary of the Triwizard Tournament. So rest assured, the following questions would be in honour of the
same. Read the following statements before answering questions 4 and 5.
(a) The competition is held every five years.
(b) As a security restriction, applicants had to atleast be of the Wizarding Age of Majority (17 years) to participate in the tournament.
4. WAF numEligible that takes a year as input. The function returns the
number of students (from Hogwarts) that would be eligible to participate
in the tournament that year. And if there is no Triwizard tournament in
a given year return Diminuendo! (Note: You can reuse use previously
created functions, from previous questions).
Sample Run > (numEligible 2005)
Sample Output 217
Sample Run > (numEligible 2001)
Sample Output Diminuendo!
Sample Run > (numStud 1900)
Sample Output Diminuendo!
Sample Run > (numEligible 2k1)

Sample Output Confundus Charm!


5. WAF everEligible that takes a students year of birth as input. This
function returns as output a boolean value- whether a student will ever
be eligible for the Triwizard Tournament or not; Return true (#t) if yes,
false (#f) if not.
Sample Run > (everEligible 1991)
Sample Output #f
Sample Run > (everEligible 2008)
Sample Output #t
6. There can be as many applicants as the number of eligible students (as
calculated in question 4). But the Triwizard Tournament, as the name entails, is between 3 wizards! So preliminarily, there is a 1-on-1 duel between
two randomly picked applicants. These 1-on-1 duels are held in a knock
out manner. They are conducted until exactly 3 participants are left.
WAF numDuels that takes number of applicants as input, and returns
the minimum number of 1-on-1 matches held that leaves out 3 participants. (Hint: Remember the puzzle from Prof Viswanath sirs class?)
All the best!

You might also like