HackerRank Python - Matrix Script




Print the decoded matrix script.



  1. #!/bin/python3
  2. import math
  3. import os
  4. import random
  5. import re
  6. import sys
  7. first_multiple_input = input().rstrip().split()
  8. n = int(first_multiple_input[0])
  9. m = int(first_multiple_input[1])
  10. matrix = []
  11. for _ in range(n):
  12. matrix_item = input()
  13. matrix.append(matrix_item)
  14. decoded_message = ""
  15. for column in range(m):
  16. for row in range(n):
  17. decoded_message += matrix[row][column]
  18. print(re.sub(r"(?<=\w)([^\w]+)(?=\w)", " ", decoded_message))




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube