View Single Post
  #13  
Old 11-09-2011, 06:37 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Well, I was trying to come up with some sort of algorithm for this which took into account the largest potential area the cars could take up, as well as the least amount of area the cars could take up, and came up with this. The problem is, I can only work it out if the width of the cars are known, as I don't really know how this can be solved without knowing this.

PHP Code:
function onCreated(){
  
  
temp.100;
  
temp.car_length 2;
  
temp.car_width 2;    // Because I can't do it with an unknown value

  /* Using Pythagoras' theorm, I found the hypotenuse of the triangle inside 
      the car, which also gave me the radius of the circle around the car,
      which represents the total amount of area it could potentially take up, as
      they are parking randomly.
  */
  
temp.car_potential_area = ((car_length 2)^+ (car_width 2)^2)^0.5;
  
  
/* I then used the radius of the circle found above so that I could
      calculate the length of the radius between the center of the inner
      circle and the center of the car's "circle"
  */
  
temp.car_middle = (pi 2) + car_potential_area;

  
/* And then, using the radius from above, calculated how many cars 
      could fit along the circumference of this line, like beads on a string
      if you imagine the circles around the cars.
  */
  
temp.parking_places pi car_middle;

  
/* From this, I divided the total parking space by the diameter of the
      circle of potential area they could take up, to get a decimal value
      for the number of cars.
  */
  
temp.cars parking_places / (car_potential_size 2);

  
// Echoes a value for the minimum number of cars (38 cars)
  
echo(int(temp.cars)); // Integer because you can't have a fraction of a car

  /* A value for the maximum number of cars, parking side by side around the
      circle
  */
  
temp.max_cars parking_places car_length;

  
// Echoes a value for the maximum number of cars if they were lined up side by side (54 cars)
  
echo(int(temp.max_cars));

So my answer is that there could be any number between 38 and 54 cars in the parking lot.
This is the best I could come up with, tell me if I'm along the right lines.
__________________

Intelligence without ambition is like a bird without wings.


Last edited by iBeatz; 11-09-2011 at 07:01 PM..
Reply With Quote