Sort by

recency

|

573 Discussions

|

  • + 0 comments
    import sys, re
    
    matrix = sys.stdin.read().splitlines()
    
    columns_count = int(matrix[0][2])
    matrix = matrix[1:]
    columns = []
    i=0
    
    for _ in range(columns_count):   
        for line in matrix:
            columns.append(line[i])
    
        i+=1
    
    columns = ''.join(columns)
    decrypted = re.sub(r'(?<=\w)[^\w]+(?=\w)', ' ', columns)
    
    print(decrypted)
    
  • + 0 comments

    was trying numpy, but no such module

    string = ''.join([''.join(y) for y in (np.array([list(x) for x in matrix]).T.tolist())])

  • + 0 comments
    import re
    
    n, m = map(int, input().split())
    
    matrix = [input() for _ in range(n)]
    decoded = ''.join(sum(zip(*matrix), ()))
    
    pattern = r'(?<=\w)([^\w]+)(?=\w)'
    print(re.sub(pattern, ' ', decoded))
    
  • + 1 comment

    Disappointed to see no answer using findall directly (I know why). Here is my solution with findall

    pat = r'^[!@#$%&\s]*[0-9A-Za-z]*[!@#$%&\s]*$|^[!@#$%&\s]*[0-9A-Za-z]+|[0-9A-Za-z]+[!@#$%&\s]*$|[0-9A-Za-z]+'
    decoded_script = re.findall(pat, script)
    print(' '.join(decoded_script))
    
  • + 0 comments

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