Sort by

recency

|

331 Discussions

|

  • + 0 comments
    import re
    s,k = [input() for _ in range(2)]
    p = r'(?=(%s))' % re.escape(k)
    print("\n".join("(%s, %s)"%(match.start(1),match.end(1)-1) for match in re.finditer(p, s)) or "(-1, -1)")
    
  • + 0 comments
    import re
    
    string = input()
    k = input()
    
    pattern = f"(?=({k}))"
    matches = re.finditer(pattern, string)
    indices = []
    
    for match in matches:
        indices.append((match.start(), match.start() + len(k) - 1))
    
    if not indices:
        print((-1, -1))
    else:
        for x in indices:
            print(x)
    
  • + 0 comments

    ` import re

    s = input().strip() k = input().strip()

    found = False

    for match in re.finditer(r'(?=('+re.escape(k)+'))', s): found = True start_index = match.start(1) end_index = match.end(1) - 1 print((start_index, end_index))

    if not found: print((-1, -1))

    if not found: print((-1, -1))

  • + 0 comments
    import re
    
    s, k = input(), input()
    
    idx = [(m.start(1), m.end(1) -1) for m in re.finditer(fr"(?=({k}))", s)]
    
    print(*idx or [(-1, -1)], sep="\n")
    
  • + 0 comments
    import re
    
    s = input()
    k = input()
    
    result = [(i.start(),i.end()+len(k)-1) for i in re.finditer('(?={0})'.format(k), s)]
    if len(result) > 0:
        for n in result:
            print(n)
    else:
        print((-1,-1))