Our ultimate goal in this problem set is to help the Housing Office determine what incoming freshthings can be put in the same room, and to determine what dorms will need to be converted to a different environment (note that some of them may already have an appropriate atmosphere for some of these new students!).
Begin by loading the code for problem set 4. This defines the procedures listed above, and the list *order* and the initial database entering-class. The loaded code also defines map, filter, and accumulate from the book, which you may find useful in doing the exercises below. In grading problem sets, we will be considering the elegance of your code, not only whether or not it ``works.'' So it will be to your advantage to use aggregate operations when they are appropriate. In fact, some of the exercises below will be very cumbersome to write (and debug!) if you do not use the aggregate operators. It would be a good idea to reread pages 112-118 of the book, and to look again at exercise 2.35 before starting in on these programming exercises.
Check the 6.001 discussion forum for computer-ex-01
Look here
for information about the forum.
| |
Implement a procedure that takes as argument a table and a list of conditions and returns the list of all freshthings in the table who could live under those conditions. Assume that if a freshthing does not list a preference in a category, then he/she/it will be comfortable with any choice.
For instance, with our sample entering class, if the list of conditions is (sulfur, 350K-370K, ultraviolet), your procedure should return all freshthings who could live with a sulfur atmosphere, a 350K-370K temperature range, and ultraviolet light--namely, Amoeboid1, Amoeboid2, and Amoeboid3. Note that this result does not include Amoeboid4, since Amoeboid4 specified visible light; but the result does include Amoeboid1, since Amoeboid1 did not specify any preference for spectrum. Assume that the list of conditions starts with an atmosphere preference, lists the preferences in order of importance, and does not skip over any categories. That is, the list could be (methane) or (methane, 260K-270K, infrared, random), but not (260K-270K) or (methane, infrared, random). Turn in a listing of your procedure together with some tests to demonstrate that it works.
By the way, the Boston Licensing Board has just informed MIT that it will not allow students to live in ethanol-atmosphere housing in the future. How would you use your procedure to find out how many students could be displaced by this ruling?
Check the 6.001 discussion forum for computer-ex-02
Look here
for information about the forum.
| |
Generalize your answer to exercise 2 so that the list of conditions can include the symbol * to indicate that a category is skipped over. For example, using (sulfur, *, visible) should return all freshthings except those who specified an atmosphere other than sulfur or a spectrum other than visible--namely, Amoeboid1 and Amoeboid4. Similarly, (*, *, ultraviolet) should return the list of all freshthings who can live in an ultraviolet spectrum, i.e., all freshthings except those who specified a preference for a spectrum other than ultraviolet. (There are 10 such freshthings in our sample entering class.)
Note that the preferences must still list the categories in order and include a * for each category that is skipped over. Using your program, find all the freshthings who could live with an ultraviolet spectrum and a night cycle. Find all the freshthings who could live with a day cycle.
In this problem, especially, it will really help to think in terms of aggregate operations. If you don't do this, it is easy to get lost in a maze of list operations. So plan your work carefully.
Check the 6.001 discussion forum for computer-ex-03
Look here
for information about the forum.
| |
Implement the canonicalize-input procedure you designed for tutorial exercise 5, and turn in the procedure together with some tests to show that it works.
Check the 6.001 discussion forum for computer-ex-04
Look here
for information about the forum.
| |
Our system currently requires freshthings to indicate their preferences for categories using our ordering of importance (atmosphere, temperature, spectrum, cycle). But this is too rigid. For instance, my friend Gleep, from the second planet around Proxima Centauri, is comfortable over a reasonably wide range of temperatures and atmospheres, but Gleep really needs to be strongly illuminated with visible light because he is photosynthetic. Wouldn't it be better to allow freshthings to give only the characteristics that actually matter to them, independent of order?
Discuss how you would redesign the system to permit this. The new system will need to accept input from freshthings, enter this into the table, and access the table to find all freshthings who can live under various conditions (as in exercise 3 above).
Write a clear but brief (one or two page) explanation describing which parts of the system need to be changed, and how. This is a very open-ended question and there are lots of ways to go about this. In grading, we will be more interested in the clarity of your explanation than in details of coding. For example, you should describe any new procedures that must be written and any old procedures that must be modified and give precise prescriptions of how they should behave.
If you want to implement some or all of your design, that's fine, but you need not write any code at all for this problem, provided you give a clear explanation of how the new system will work and a clear description of what code needs to be written. ``Clear'' means that another person, say another student in the class, could read your description and write the actual code without difficulty.
Check the 6.001 discussion forum for computer-ex-05
Look here
for information about the forum.
| |
Turn in answers to the following questions along with your answers to the questions in the problem set: