def ParseResidentPages(resident_pages):
  """Parses and converts the residency data into a list where
  the index corresponds to the page number and the value 1 if resident
  and 0 otherwise.

  |resident_pages| contains a string of resident pages:
      0
      1
      ...
      ...
      N

  Args:
    resident_pages: (str) As returned by ReadFileFromDevice()

  Returns:
    (list) Pages list.
  """
  pages_list = []
  expected = 0
  for page in resident_pages.splitlines():
    while expected < int(page):
      pages_list.append(0)
      expected += 1

    pages_list.append(1)
    expected += 1;
  return pages_list