CSci 1301: Takehome 1

Due: Tuesday, October 24 at 11:59pm by e-mail (no late work accepted)

Total: 30 points

This is individual work. You are not allowed to spend more than 6 hours on this test. This includes any reading that you do to help you solve the problems.

Make sure to write your name in the file(s) you submit. You may submit one or two files.

Use helper functions as needed. All your functions (including all those you use in big-bang) must have documentation with the types of parameters and results, a function description, and, whenever possible, check-expect tests.
When defining your own structures, clearly explain what all the fields mean.
Comments, helpful variable names, and good code style and formatting are a very important part of your grade. You don't have to look for the shortest solution, but you should eliminate unnecessary code repetition if possible (use helper functions).

Task 1 (5 points): duplicating the middle character of a string

Write a function duplicate-middle that consumes a string and if the string has an odd number of characters, it returns the string in which the middle character is repeated twice. If the string has an even number of characters, it is returned unchanged. The following are some tests for the function; you need to add more tests since there are cases that are not tested here. Please make sure to write the signature and the (more precise) description.


(check-expect (duplicate-middle "a") "aa")
(check-expect (duplicate-middle "son") "soon")
  

Task 2 (25 points): a world problem

Your goal is to implement an object that moves on the screen. The object has a direction in which it's moving and is represented by a simple arrow pointing in its direction, in this case "up":
I used the function isosceles-triangle for this image. Your image may be the same or different, as long as it's using Racket image library (not an imported image).

The world program that you need to write is as follows:

If something is not working, please comment it out and write comments about why you think it's not working and how you would be going about fixing it if you had more time. Make sure that the code you submit runs, even if it doesn't implement all of the functionality.

Your work will be graded based on:

Happy programming!

What to submit

Submit all your files as attachements in an email to me with the subject "Midterm 1" followed by your name or initials. Please include your name and a task number at the beginning of each file, in a comment. In your email message please include any comments about what works and what doesn't, as well as thoughts on how you would've continued if you had more time (if you run out of time). Also please include the total time you spent on the test.


CSci 1301 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.