943,633 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 551
  • C++ RSS
Oct 15th, 2008
0

more counting :(

Expand Post »
okay...i've got another wired counting problem, this time it's about rectangles!
gotta find the minimum number of lines to divide a rectangle into squares! i went for...ehh
well a dumb idea of cutting the max square off, and cutting the little ones recursively, but...
doesn't always work.
you're given the two dimensions of the rectangle...that's it. both are integers btw.
Similar Threads
Reputation Points: 12
Solved Threads: 5
Junior Poster in Training
gregorynoob is offline Offline
86 posts
since Jun 2008
Oct 15th, 2008
0

Re: more counting :(

Find a point that is as far in as the length of the height (assuming height < width). Then you have a square and a new rectangle. Repeat the procedure using the shortest side as the side of the new square you want to cut. Do this until S1 == S2.
Reputation Points: 104
Solved Threads: 27
Posting Whiz in Training
dmanw100 is offline Offline
239 posts
since Apr 2008
Oct 15th, 2008
0

Re: more counting :(

Its confusing but post some code once you try it out.
Reputation Points: 104
Solved Threads: 27
Posting Whiz in Training
dmanw100 is offline Offline
239 posts
since Apr 2008
Oct 15th, 2008
0

Re: more counting :(

but i need the minimum...that's not the minimum...try for example with dimensions 6*7...
Reputation Points: 12
Solved Threads: 5
Junior Poster in Training
gregorynoob is offline Offline
86 posts
since Jun 2008
Oct 15th, 2008
0

Re: more counting :(

How many squares are you supposed to build using your rectangle ?

For instance if the length is twice the width or vice versa, you'd be able to split the rectangle into 4 squares using 2 lines. And then you could keep splitting it making smaller and smaller squares ..
Reputation Points: 161
Solved Threads: 43
Posting Whiz
stilllearning is offline Offline
309 posts
since Oct 2007
Oct 16th, 2008
0

Re: more counting :(

My method will return 8 squares. I don't know if I quite understand the output you want from 7*8? Give me an example of what squares you want to get...
Reputation Points: 104
Solved Threads: 27
Posting Whiz in Training
dmanw100 is offline Offline
239 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: deleting a file
Next Thread in C++ Forum Timeline: Largest Variable?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC