View Single Post
  #21  
Old 06-15-2008, 04:49 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Not sure if I entirely understood the task, but I suppose this should work?

PHP Code:
function onCreated() {
  
temp.students_incompatible = {{1,2},{3,49}};
  
temp.students_total = new[400];
  
temp.house_list = {};
  
  while (
temp.house_list.size() < 100) {
    
temp.0;
    while (
temp.students_total[temp.i] == 1)
      
temp.++;
    
temp.students_total[temp.i] = 1;
    
temp.temp.i;
    
    
temp.go false;
    while (
temp.students_total[temp.j] == || !temp.go) {
      if ((@ {
temp.1,temp.1}) in temp.students_incompatible) {
        
temp.go false;
        
temp.++;
      }
      else if ((@ {
temp.1,temp.1}) in temp.students_incompatible) {
        
temp.go false;
        
temp.++;
      }
      else if (
temp.students_total[temp.j] == 1)
        
temp.++;
      else
        
temp.go true;
    }
    
temp.students_total[temp.j] = 1;
    
temp.house_list.add({temp.1,temp.1});
  }
  echo(
temp.house_list);

Time: 0.008579015
__________________

Last edited by Dan; 06-15-2008 at 05:07 PM.. Reason: Added time.
Reply With Quote