new_contents: # CORRECT SPECIFICATION:
  #
  # the Queue class provides a fized-size FIFO queue of integers
  #
  # the constructor takes a single parameter: an integer >0 that
  # is the maximum number of elements the queue can hold
  #
  # empty() returns True iff the queue holds no elements
  #
  # full() returns True iff the queue cannot hold any more elements
  #
  # enqueue(i) attempts to put the integer i into the queue; it returns
  # True if successful and False if the queue is full
  #
  # dequeue() removes an integer from the queue and returns it,
  # or else returns None if the queue is empty
  #
  # Modified by Thiago Figueiró at 21/11/2015 00:43
  # - Modified the 'checkRep' method
  
  import array
  
  class Queue:
      def __init__(self,size_max):
          assert size_max > 0
          self.max = size_max
          self.head = 0
          self.tail = 0
          self.size = 0
          self.data = array.array('i', range(size_max))
  
      def empty(self):
          return self.size == 0
  
      def full(self):
          return self.size == self.max
  
      def enqueue(self,x):
          if self.size == self.max:
              return False
          self.data[self.tail] = x
          self.size += 1
          self.tail += 1
          if self.tail == self.max:
              self.tail = 1
          return True
  
      def dequeue(self):
          if self.size == 0:
              return None
          x = self.data[self.head]
          self.size -= 1
          self.head += 1
          if self.head == self.max:
              self.head = 0
          return x
  
      def checkRep(self):     
      # When the program starts, it MUST have a size bigger than 0 and
      # smaller than the max size of it.
          assert self.size >= 0 and self.size <= self.max
          
      # After queue, the tail will be different than head and the difference
      # MUST be the size of the array
          if self.tail > self.head:
              assert (self.tail - self.head == self.size)
          if self.tail < self.max:
              assert (self.max - self.tail == self.size)
              
      # However, if the tail is equal to the head, then the size either is zero
      # or the size is the maximum size of the array
          if self.tail == self.head:
              assert (self.size == 0) or (self.size == self.max)            
          return
  
  
subject: Complete the Checkrep assignment