<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _format_episode_name(names):
 """Takes a list of episode names, formats them into a string. If two names are supplied, such as "Pilot (1)" and "Pilot (2)", the returned string will be "Pilot (1-2)". Note that the first number is not required, for example passing "Pilot" and "Pilot (2)" will also result in returning "Pilot (1-2)". If two different episode names are found, such as "The first", and "Something else" it will return "The first, Something else" """

    if len(names) == 1:
        return names[0]

    found_name = ''
    epname = None
    epno = None
    numbers = []
    for cname in names:
        match = re.match(r'(.*) \(([0-9]+)\)$', cname)
        if found_name != '' and (not match or epname != found_name):
            # An episode didn't match
            return cfg.CONF.multiep_join_name_with.join(names)

        if match:
            epname, epno = match.group(1), match.group(2)
        else:  # assume that this is the first episode, without number
            epname = cname
            epno = 1
        found_name = epname
        numbers.append(int(epno))

    return cfg.CONF.multiep_format % {'epname': found_name,
                                      'episodemin': min(numbers),
                                      'episodemax': max(numbers)}