Sort by

recency

|

569 Discussions

|

  • + 0 comments

    print(re.sub("(?<=\w)(\W+)(?=\w)"," ","".join([matrix[j][i] for i in range(m) for j in range(n)])))

  • + 0 comments
    import re
    first_multiple_input = input().rstrip().split()
    n = int(first_multiple_input[0])
    m = int(first_multiple_input[1])
    matrix = []
    for _ in range(n):
        matrix_item = input()
        matrix.append(matrix_item)
    s = ''.join(matrix[y][x] for x in range(m) for y in range(n))
    p = r'(?<=[a-zA-Z0-9])[!@#$%&\s]+(?=[a-zA-Z0-9])'
    print(re.sub(p, ' ', s))
    
  • + 0 comments

    matrix = [list(i) for i in zip(*matrix)] matrix = sum(matrix, []) string = "".join(matrix)

    pattern = "[A-Za-z0-9][^A-Za-z0-9]+[A-Za-z0-9]"

    betweens = re.findall(pattern, string) for substr in betweens: string = string.replace(substr[1:-1], ' ', 1)

    print(string)

  • + 0 comments
    import re
    
    first_multiple_input = input().rstrip().split()
    
    n = int(first_multiple_input[0])
    
    m = int(first_multiple_input[1])
    
    matrix = []
    
    for _ in range(n):
        matrix_item = input()
        matrix.append(matrix_item)
    decode = list(zip(*matrix))
    decode_string = "".join(map(lambda string: "".join(string), decode))
    
    pattern = re.compile(r"((?<=\w)([!@#$%&\s]+)(?=\w))|\s\s")
    neo = re.sub(pattern, " ", decode_string)
    print(neo)
    
  • + 0 comments

    this is my code, I replace positive lookbehind and positivei lookahead condition into \b meta string.

    import math
    import os
    import random
    import re
    import sys
    
    
    
    N, M = map(int, input().split())
    
    matrix = []
    
    for _ in range(N):
        matrix_item = input()
        matrix.append(matrix_item)
    
    string = ''.join(matrix)
    decode = '' 
    
    for i in range(M):
        for index in range(i, len(string), M):
            decode += string[index]
            
    decode = re.sub('\\b\W+\\b', ' ', decode)
    print(decode)