File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programming Diversions and the fly likes [Easy]Inside a rectangle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "[Easy]Inside a rectangle" Watch "[Easy]Inside a rectangle" New topic
Author

[Easy]Inside a rectangle

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Recently appeared in one regional newspaper.
Draw a rectangle ABCD with length 'x' and width 'y'.From point A ,draw an angle bisector line AE(bisecting angle BAD) ,intersecting BC at E.From point E,draw a line perpendicular to AE,intersecting CD/AD at F.Continue this procedure until you meet in one of the corners of the rectangle.Question is:
1)Is this procedure infinite(i.e.unable to meet at one of the corners) or finite? For what ratios of x/y this procedure is finite?
2)How many of such lines AE,EF.. can be drawn before meeting one of the corners?Answer in terms of x and y.
[ October 27, 2003: Message edited by: Capablanca Kepler ]

MH
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Ok, Here is what I did:
Total horizontal distance traversed = Total vertical distance traversed = L.C.M. of(x,y).
If x=y,there will be only one line.If x and y are natural numbers(and y is not a multiple of x) ,then total number of lines before meeting one of the corners is x+y-1.If y = Nx,then total number of lines will be N.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
If x and y are natural numbers(and y is not a multiple of x) ,then total number of lines before meeting one of the corners is x+y-1.
If x = y = 1, then shouldn't the number of walls before hitting a corner be 0? And if x = 30, y = 40, shouldn't the number of walls be 5?


"I'm not back." - Bill Harding, Twister
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Thanks for corrcetion,I think then we have to make 30/40 -->3/4 so that number of lines(of type AE,EF etc) for the rectagles of sizes 3/4 or 15/20 or 30/40 etc is 3+4-1 = 6.So 6 lines can be drawn before reaching the corner of the rectagle.If rectangle is 30/41 then I think number of lines will be 30+41-1 = 70.
[ October 29, 2003: Message edited by: Capablanca Kepler ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Easy]Inside a rectangle