Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 11-09-2011, 07:38 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by iBeatz View Post
How could you not use pi to solve this? o_o
Because the lot isn't 100*pi or 4*arctan(1/5)-arctan(1/239) or sqrt(1+sqrt(1+sqrt(1+...))) units, it's 100 units.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #17  
Old 11-09-2011, 09:16 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Crow View Post
No. Programming exercises are not about things you may or may not need, though. They present problems for you to reflect on. Complicated problems that, when solved, can give you an idea on how to tackle similar ones in the future.
Maybe more than one person will participate next time. Who knows
__________________
Reply With Quote
  #18  
Old 11-09-2011, 09:22 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xAndrewx View Post
Maybe more than one person will participate next time. Who knows
I can't see this being over yet.
Reply With Quote
  #19  
Old 11-10-2011, 12:22 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
They could:

1. Paint the lines so there's at least 2.5 units of space for each car.
2. Have offenders towed/exploded for not staying within the lines of their spot.

So the solution to me is N / 2.5
__________________
Quote:
Reply With Quote
  #20  
Old 11-10-2011, 12:29 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
How many floors does this parking lot contain?
Reply With Quote
  #21  
Old 11-10-2011, 10:35 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by fowlplay4 View Post
They could:

1. Paint the lines so there's at least 2.5 units of space for each car.
2. Have offenders towed/exploded for not staying within the lines of their spot.

So the solution to me is N / 2.5
Heh, nope.

Quote:
Originally Posted by ffcmike View Post
How many floors does this parking lot contain?
Just 1.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #22  
Old 11-10-2011, 11:27 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Maybe just make a normal car park and you'd be right.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #23  
Old 11-11-2011, 02:57 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Quote:
Originally Posted by Gunderak View Post
Maybe just make a normal car park and you'd be right.
Why not test out your theory? Tolnaftate will tell you if you're correct or not
Reply With Quote
  #24  
Old 11-11-2011, 03:45 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Began the equation by assuming the fact that the lot was circular was essentially an extra detail that mattered very little to the eventual outcome since the circumference can basically be regarded as a circle laid out flat. So assuming a 100 unit long straight line, and a gap of 1 unit between the cars as the highest gap (rather than say 1.99999 repeated which would lead to 25 cars instead of whatever limit you said later), came up with this code that would linearly determine how many cars would fit.

PHP Code:
function onCreated(){
  
temp.val1 findMin(1002);
  
temp.val2 findMax(1002);
  echo(
val1);
  echo(
val2);
  for(
temp.0100i++){
    
temp.val3 += findRand(1002);
  }
  echo(
val3/100);
}

function 
findRand(ni){
  
temp.space 0;
  
temp.gap random(12);
  
temp.isgap false;
  
temp.cars 0;
  while(
space n){
    
isgap = !isgap;
    if(
isgap){
      
space += gap;
    }
    else{
      
space += i;
      
cars++;
    }
  }
  return 
cars;
}

function 
findMin(ni){
  
temp.space 0;
  
temp.gap 1;
  
temp.isgap false;
  
temp.cars 0;
  while(
space n){
    
isgap = !isgap;
    if(
isgap){
      
space += gap;
    }
    else{
      
space += i;
      
cars++;
    }
  }
  return 
cars;
}

function 
findMax(ni){
  return 
int(n/i);

Output:
PHP Code:
33
50
40.87 

The results if plotted for each random iteration would wind up being a sort of diamond leading around the value of min + max / 2, causing the average to approach that value.
Reply With Quote
  #25  
Old 11-11-2011, 08:01 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Mark Sir Link View Post
Began the equation by assuming the fact that the lot was circular was essentially an extra detail that mattered very little to the eventual outcome since the circumference can basically be regarded as a circle laid out flat. So assuming a 100 unit long straight line, and a gap of 1 unit between the cars as the highest gap...
Gaps between cars should be either 0 units or 1 unit. The cars have to line up with the units. Additionally, the lot being circular does have an impact on the answer, but somehow considering it as a linear lot is a step in the right direction.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #26  
Old 11-11-2011, 11:25 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Tolnaftate2004 View Post
Gaps between cars should be either 0 units or 1 unit. The cars have to line up with the units. Additionally, the lot being circular does have an impact on the answer, but somehow considering it as a linear lot is a step in the right direction.
the only significant impact I can see from the lot being circular is the relationship of the car at the theoretical start and ending points, meaning if a car were attempted to be parked at N-1 marker, it should then consider if there is a car at 1 or 2 (0 or 1 as array form).

I'll adjust for that and shift to using an array since the gaps remaining integer makes the question tremendously easier.

Or it'd be getting more complex into relational math where the fact that the car is tangent to whatever point on the circle has some profound effect on how the cars can align and modifying the math to account for that but I don't think that's what you were going for
Reply With Quote
  #27  
Old 11-11-2011, 11:59 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
The length of the array is increased to units + 1 to reconcile the idea of each element of the array scaling from the beginning of that index that index to the beginning of the next, IE, 0-1, 1-2, ..., 100-0

It doesn't matter if temp.isgap starts as true or false, and it's possible to see a sort of representation of how the cars align by returning lot instead of this.parkedcars.




Code:
PHP Code:
function onCreated(){
  
this.gapmax 1;
  
this.gapmin 0;
  
temp.val1 findMin(1002);
  
temp.val2 findMax(1002);
  echo(
val1);
  echo(
val2);
  for(
temp.0100i++){
    
temp.val3 += findRand(1002);
  }
  echo(
val3/100);
}

function 
findMin(unitscarlength){
  
this.parkedcars 0;
  
temp.isgap false;
  for(
temp.0units+1i++){
    
temp.lot.add("E");
  }
  for(
temp.0lot.size(); i++){
    
temp.isgap = !temp.isgap;
    if(!
temp.isgap){
      
lot parkCar(loti);
      
i++;
    }
  }
  return 
this.parkedcars
}

function 
findRand(unitscarlength){
  
temp.int(random(0,2));
  if(
== 0){
    return 
findMin(unitscarlength);
  }
  else{
    return 
findMax(unitscarlength);
  }
}

function 
parkCar(arri){
  if(
== arr.size()){
    
temp.val 0;
  }
  else{
    
temp.val 1;
  }
  if(
arr[i] == "E" && arr[val] == "E"){
    
arr[i] = "C";
    
arr[val] = "C";
    
this.parkedcars++;
  }
  return 
arr;
}

function 
findMax(unitscarlength){
  return 
int((units+1)/carlength); 

Output:
PHP Code:
34
50
42.96 
Reply With Quote
  #28  
Old 11-11-2011, 12:24 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Quote:
Originally Posted by Tricxta View Post
Why not test out your theory? Tolnaftate will tell you if you're correct or not
Attached Thumbnails
Click image for larger version

Name:	Carpark.PNG
Views:	117
Size:	10.0 KB
ID:	53924  
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 11-11-2011 at 03:46 PM..
Reply With Quote
  #29  
Old 11-11-2011, 06:12 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Not gonna lie, I see this circular parking lot as this.


and time
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #30  
Old 11-11-2011, 06:17 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
lmao.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.