• My function passes in idle but not on site.

 

I would like to give some feedback about ...

From: https://www.checkio.org/mission/break-rings/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36

Code:

count = 0


def l(rings):
    d = {}
    for (x, y) in rings:
        if x not in d:
            d[x] = [y]
        else:
            d[x].append(y)

        if y not in d:
            d[y] = [x]
        else:
            d[y].append(x)
    long = []
    for x in d:
        long.append((len(d[x]), x))
    long.sort(reverse = True)
    global count
    count += 1
    return long[0][1]

def r(rings, long):
    new = []
    for (x, y) in rings:
        if x != long and y != long:
            new.append({x, y})
    return new


def break_rings(rings):
    global count
    while len(rings) != 0:
        rings = r(rings, l(rings))
    return count

I put break_rings(({1,2},{1,3},{1,4},{2,3},{2,4},{3,4},)) in idle and the result was 3 But in site, the result was 6.. What can I do..?