Last active
April 14, 2016 05:24
-
-
Save Tsunamicom/b3b1f53720eb9f6cac42020b2486ea51 to your computer and use it in GitHub Desktop.
Hackerrank: Matrix Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3.4 Solution to Matrix Script Problem by Kurtis Mackey | |
# https://www.hackerrank.com/challenges/matrix-script | |
import re | |
# Import original script | |
matrix = list() | |
for _ in range(int(input().split()[0])): | |
matrix.append(list(input())) | |
# Rotate the matrix | |
matrix = list(zip(*matrix)) | |
# Prep regex sample | |
sample = str() | |
for subset in matrix: | |
for letter in subset: | |
sample += letter | |
# Substitute invalid characters with a space | |
print(re.sub(r'(?<=\w)([^\w\d]+)(?=\w)', ' ', sample)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment