Sort by

recency

|

407 Discussions

|

  • + 0 comments
    import re
    
    pattern = r"(?<=[\:\, ])+[#]+([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})"
    
    for _ in range(int(input())):
        line = input()
        res = re.findall(pattern, line)
        
        if res:
            [print("#"+i) for i in res]
        else:
            pass
    
  • + 0 comments

    My test case 4 is failing for some reason.. coz when i run it on my local machine with the same input, it works but HackerRank is not accepting my code. This is my code:

    import re
    
    regex = r"(#[0-9a-fA-F]{6})|(#[0-9a-fA-F]{3})"
    res = []
    
    n = int(input())
     
    while n > 0:
         css = input().split()
         if len(css) < 2:
             pass
         else:
             for item in css:
                 m = re.findall(regex, item)
                 if m:
                     res += m
         n -= 1
    
    for element in res:
         for code in element:
             if code != '':
                 print(code)
    
  • + 0 comments
    import re
    for _ in range(int(input())):
        line = input()
        pattern = re.compile(r'(?<=[\s:])#(?:[a-fA-F0-9]{6}|[a-fA-F0-9]{3})')
        re.sub(pattern,lambda m: print(m.group()),line)
    
  • + 0 comments
    import re
    m=[]
    for _ in range(int(input())):
        l=re.findall(r"\#[0-9a-fA-F]{3,6}(?=\S)",input())
        if l:
            m.append(l)
    for i in m:
        for j in i:
            print(j)
    
  • + 0 comments

    uyrjrjefdfrgvbjufikuvyrfe38freyvgryyfoe9f8eruoivyovujfreifruyt8fegtygjufkposjdvhnbdureift8y7eft9uyioepwfitvdfguftrufrjety7f89upwfiotvfutfre8ftvy8ue[fkipotuvgfkddtrekft8jy