Monday, March 3, 2008

2008 Scripting Games!! Beg. Event 10

The last event for the 2008 Scripting Games. Next year I'll be competing in the Advanced category. As for now here is my solution for Event 10.

   1:  $arrFrames = 2,5,7,"/",8,1,"X",9,"/",5,3,7,0,4,5,"X",2,0
   2:  $score=0
   3:  for ($i=0;$i -le ($arrframes.length-1);$i++) {
   4:  
   5:  if (($arrFrames[$i] -eq "X") -and ($arrFrames[$i+1] -eq "X") -and ($arrFrames[$i+2] -eq "X")) {
   6:          $score+=30
   7:      }
   8:      elseif (($arrFrames[$i] -eq "X") -and ($arrFrames[$i+1] -eq "X")) {
   9:          $score+=20 + ($arrFrames[$i+2])
  10:      }
  11:      elseif (($arrFrames[$i] -eq "X") -and ($arrFrames[$i+2] -eq "/")) {
  12:          $score+=20
  13:      }
  14:      elseif ($arrFrames[$i] -eq "X") {
  15:          $score+=10 + ($arrFrames[$i+1] + $arrFrames[$i+2])
  16:      }
  17:  if (($arrFrames[$i] -eq "/") -and ($arrFrames[$i+1] -eq "X")) {
  18:          $score+=10 + (10 - ($arrFrames[$i-1]))
  19:          }
  20:      elseif ($arrFrames[$i] -eq "/") {
  21:          $score+=(10 - ($arrFrames[$i-1])) + ($arrFrames[$i+1])    
  22:      }
  23:  if ($arrFrames[$i] -is [int]) {
  24:  $score+=$arrFrames[$i]
  25:  }
  26:  
  27:  }
  28:  "My Score: $score"

Thats it for the 2008 Games! See you next year at the Advanced Events!

No comments: