def parse_problem_name(problem_name):
  """Determines if problem_name specifies a copy and/or reversal.

  Args:
    problem_name: A string containing a single problem name from FLAGS.problems.

  Returns:
    base_name: A string with the base problem name.
    was_reversed: A boolean.
    was_copy: A boolean.
  """
  # Recursively strip tags until we reach a base name.
  if problem_name.endswith("_rev"):
    base, _, was_copy = parse_problem_name(problem_name[:-4])
    return base, True, was_copy
  elif problem_name.endswith("_copy"):
    base, was_reversed, _ = parse_problem_name(problem_name[:-5])
    return base, was_reversed, True
  return problem_name, False, False