Sort by

recency

|

315 Discussions

|

  • + 0 comments
    import re
    pattern = r'(?<= )(&&|\|\|)(?= )'
    replace = lambda m : 'and' if m.group() == '&&' else 'or'
    print(*(re.sub(pattern,replace,input()) for _ in range(int(input()))),sep='\n')
    
  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import re
    print(*(re.sub(r'(?<= )(&&|\|\|)(?= )',
        lambda m : 'and' if m.group() == '&&' else 'or',
        input()) 
        for _ in range(int(input()))),sep='\n')
    
  • + 0 comments

    Can anyone help, why this doesnt pass all test cases:

    n = int(input()) b = [input() for _ in range(n)] b = "\n".join(b) replacements = [(" && ", "and"), (" || ", "or")] [b := b.replace(x, y) for x, y in replacements] print(b)

  • + 0 comments
    import re,sys
    
    data = sys.stdin.read().splitlines()
    remaining = "\n".join(data[1:])
    print(re.sub(r'(?<= )([&]{2}|[|]{2})(?= )',lambda x:"and" if x.group(1)=="&&" else "or",remaining))
    
  • + 0 comments
    import re
    for _ in range(int(input())):
        line=input()
        line=re.sub(r"(?<= )(&&)(?= )","and",line)
        line=re.sub(r"(?<= )(\|\|)(?= )","or",line)
        print(line)