3 Homework 2B
Due:
Thursday, 1/18 at 9PM
This assignment is SOLO, and entirely AUTOGRADED.
What to Download:
Please start with this file, filling in where appropriate, and submit your homework to the HW2B assignment on Gradescope. This page has additional information, and allows us to format things nicely.
3.1 Problem 1
Design a function dist that takes two numbers, x and y, which are coordinates in the cartesian plane, and returns the distance from the origin. Ensure it has an reasonable signature, and run (check-contract dist) to validate the signature.
3.2 Problem 2
Design a function cube-vol that takes a number, side-len, and returns the volume of a 3D cube with sides of that length. Ensure it has an reasonable signature, and run (check-contract cube-vol) to validate the signature.
3.3 Problem 3
Design a function nor that takes two boolean inputs and returns #true only when neither of its inputs is #true. Ensure it has an reasonable signature, and run (check-contract nor) to validate the signature.
3.4 Problem 4
Design a function string-hide that takes a string and a natural number. If the number is less than or equal to the length of the string, it replaces the character at that position (the first character is position 1, second is position 2, etc) with "_", otherwise, returns the string unchanged (note: substring will be useful). Ensure it has an reasonable signature, and run (check-contract string-hide) to validate the signature.