Group(), Groups() & Groupdict()

Sort by

recency

|

265 Discussions

|

  • + 0 comments

    Using regex

    import re
    task = input()
    
    cases = set(re.findall(r"([a-zA-Z0-9])", task))
    cases = "".join(cases)
    
    pattern = f"([{cases}])(?=\\1+)"
    
    matches = re.search(pattern, task)
    
    print(matches.group(1) if matches and matches.group(1) else "-1")
    
  • + 0 comments
    s = input()
    for i in range(1,len(s)):
        if s[i].isalnum() and s[i] == s[i-1]:
            print(s[i])
            break
    else:
        print(-1)
    
  • + 0 comments
    import re
    if result := re.search(r'([a-zA-Z0-9])\1',input()):
        print(result.group(1))
    else:
        print(-1)
    
  • + 0 comments

    word = input() for i in word: if i.isalnum(): y = i+i if y in word: print(i) break else: print(-1)

  • + 0 comments
    import re
    m=re.search(r"([a-zA-Z0-9])\1+",input())
    if m:
        print(m.group(1))
    else:
        print(-1)