more counting :(

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 86
Reputation: gregorynoob is an unknown quantity at this point 
Solved Threads: 5
gregorynoob gregorynoob is offline Offline
Junior Poster in Training

more counting :(

 
0
  #1
Oct 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 160
Reputation: dmanw100 is on a distinguished road 
Solved Threads: 12
dmanw100's Avatar
dmanw100 dmanw100 is offline Offline
Junior Poster

Re: more counting :(

 
0
  #2
Oct 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 160
Reputation: dmanw100 is on a distinguished road 
Solved Threads: 12
dmanw100's Avatar
dmanw100 dmanw100 is offline Offline
Junior Poster

Re: more counting :(

 
0
  #3
Oct 15th, 2008
Its confusing but post some code once you try it out.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 86
Reputation: gregorynoob is an unknown quantity at this point 
Solved Threads: 5
gregorynoob gregorynoob is offline Offline
Junior Poster in Training

Re: more counting :(

 
0
  #4
Oct 15th, 2008
but i need the minimum...that's not the minimum...try for example with dimensions 6*7...
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 305
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Solved Threads: 43
stilllearning stilllearning is offline Offline
Posting Whiz

Re: more counting :(

 
0
  #5
Oct 15th, 2008
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 ..
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 160
Reputation: dmanw100 is on a distinguished road 
Solved Threads: 12
dmanw100's Avatar
dmanw100 dmanw100 is offline Offline
Junior Poster

Re: more counting :(

 
0
  #6
Oct 16th, 2008
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...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 379 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC