import re


def parse_no_blacks(parts):
  """
    Parse whether or not an ad indicates that there are "no black clients" allowed.
    Returns a tuple containing:
      [0]: Binary result of whether or not ad specifies "no blacks allowed"
      [1]: The input strings, minus the sections indicating "no blacks allowed"
  """
  match_patterns = [r'no ?black', r'no ?african', r'no ?aa', r'white ?(guys|men|clients) ?only',
                   r'only ?white ?(guys|men|clients)']

  remove_patterns = [r'no ?black ?or ?african', r'no ?african ?or ?black', r'men', r'guys']

  output_parts = []
  output_val = 0

  # Check each part
  for part in parts:
    o_part = part

    # Check all patterns
    for m in match_patterns:
      found = re.search(m, part)
      if found != None:
        # Found a 'no black allowed' phrase
        output_val = 1

        # Remove all relevant phrases
        for p in remove_patterns:
          o_part = re.sub(p, '', o_part)
        o_part = re.sub(m, '', o_part)

    # Append part to output (if it's not empty)
    if len(o_part) > 2:
      output_parts.append(o_part)
  
  return (output_val, output_parts)