DEV Community

Discussion on: Daily Challenge #18 - Triple Trouble

Collapse
 
_morgan_adams_ profile image
morgana

A python solution. Assumes numbers are strings.

def gettriples(n):
    s = set()
    for x in range(len(n)-2):
        if n[x]*3 == n[x:x+3]:
            s.add(n[x]*3)
    return s

def tripledouble(n1, n2):
    s1 = gettriples(n1)
    s2 = gettriples(n2)
    return bool(s1 & s2)