{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

34-Assignment-7-Where-Am-I

# 34-Assignment-7-Where-Am-I - CS107 Spring 2007 Handout 34...

This preview shows pages 1–3. Sign up to view the full content.

CS107 Handout 34 Spring 2007 May 21, 2007 Assignment 7: Where am I? Assignment written by Nick Parlante and polished off by Jerry. Here is the problem: You are in a two-dimensional space, and you are lost. Although you don't know your location, you do have a fairly accurate map that indicates where all the stars are in the space. To sort things out, you measure the approximate distance to several of the stars around you. Using the map and the distance measurements, figure out where you are. Due: Tuesday, May 29 th at 11:59 p.m. Consider the three-star system below. Suppose your observe a star which is one unit away, another star which is two units away, and a third which is three units away. You do not know the identities of the stars observed. Knowing that you are X units away from a star is equivalent to knowing that you are somewhere on a circle of radius X around that star. Below are circles of radius one, two, and three plotted around stars A, B, and C. Your location should be somewhere where three circles intersect. From that point, you must have looked out and saw the stars at their respective distances. ß and are potential points. However, cannot be your location— although it is one away from B, unfortunately it is three away from both A and C. ß must be your location. The star that was one away was B, the star that was two away was A, and the star that was three away was C. A B C ß

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 This problem demands a sophisticated algorithm. The expressiveness of the Scheme language allows you to concentrate on the ample challenges of the problem. The problem is presented in the form a problem set— you are asked to write many small functions. For the last step you will combine all of the small functions to solve the whole problem. This helps you to acclimate to Scheme-style decomposition— many short but conceptually dense functions. For each function, I have given some sample output. You should take advantage of this to test each function when it is written. Scheme is well suited to this sort of piecemeal approach. Scheme code is so dense, that debugging more than a few lines at a time becomes impossible, so you need to deal with things in little steps. I have also provided code to support the types 2-d "point" and "circle". There are routines to compute the distance between two points (easy) and to find the points of intersection of two circles (a pain). Strategy Overview What follows is one strategy for solving the problem. It's probably not the best, it's just the first solution I worked out. Feel free to experiment and try something different. Just document what you're doing. You should make extensive use of map . As raw material, you have a star map and several distance measurements. Each distance corresponds to some star, but you don't yet know which one. Pairing each distance with a particular star yields a "guess" which may or may not be right. Matching a distance with a star defines a circle, so you can think of a guess as a set of circles. So for example given the
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern