We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Python
  3. Regex and Parsing
  4. Matrix Script
  5. Discussions

Matrix Script

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • pavel_ekshine
    3 months ago+ 0 comments
    #!/bin/python3
    
    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])
    s = ''
    
    matrix = []
    
    for _ in range(n):
        matrix_item = input()
        matrix.append(matrix_item)
    
        
    s = [''.join(matrix[row][item]) for item in range(0,m) for row in range(0,n)]
    print(re.sub(r"(?<=\w)(\W+)(?=\w)", " ", ''.join(s)))
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy