Sort by

recency

|

567 Discussions

|

  • + 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)
                    
    
  • + 0 comments

    my program is in Process but it passes all the tests, does it mean it is wrong ?

  • + 0 comments

    import math import os import random import re import sys

    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)

    try these code decoded_script = re.sub(r'(?<=\w)([^\w]+)(?=\w)', ' ', decoded_script)

    print(decoded_script)