Skip to content

Instantly share code, notes, and snippets.

@lnsp
Created March 2, 2016 20:06
Show Gist options
  • Select an option

  • Save lnsp/84cbea9a76a923b28ca6 to your computer and use it in GitHub Desktop.

Select an option

Save lnsp/84cbea9a76a923b28ca6 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# (c) 2016 lsp
# /r/dailyprogrammer
def deoblique(matrix):
n = 0
for row in oblique:
p = min(n, size-1)
for i in range(len(row)):
matrix[n-p+i][p-i] = row[i]
n += 1
# read in oblique matrix
file_path = input("Enter file name:")
oblique = []
with open(file_path) as f:
for line in f:
oblique.append([int(i) for i in line.strip().split()])
# construct new one
size = max([len(s) for s in oblique])
matrix = [[0 for i in range(size)] for j in range(size)]
# run over matrix
matrix = oblique(matrix)
for row in matrix:
print(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment