Computer Programming Contest Preparation

ToolBox - Source for: 5/514/approach.txt



/home/toolbox/public_html/solutions/5/514/approach.txt
    1 
    2 carMax -- last car
    3 goal - array of carsin goal order
    4 g - current location in goal
    5 car - current car being processed
    6 
    7 empty stack
    8 car = 1
    9 push(car)
   10 car++
   11 g = 0
   12 while not empty
   13  do
   14    while (goal[g] == inspect())
   15     do
   16        g++;
   17        pop();
   18     done
   19     if (carMax > car)
   20      then
   21       push(car)
   22       car++
   23      fi
   24  done
   25 
   26 if (carMax == g) 
   27  then possible
   28  else impossible