Skip to content

Instantly share code, notes, and snippets.

@SonyaEick
Last active December 16, 2022 22:12
Show Gist options
  • Save SonyaEick/54e02808c8a8cf48ba77403def1f1e03 to your computer and use it in GitHub Desktop.
Save SonyaEick/54e02808c8a8cf48ba77403def1f1e03 to your computer and use it in GitHub Desktop.
Nearly complete code challenge for an interview.
# 1234 837 654 95 67 21
# 1234 83 7654 9 567 21
Def inner_matrix(side, rows):
If not side:
For r in rows:
print(rows[-1])
rows.pop()
Else:
For r in rows:
print(rows[0])
rows.popleft()
matrix = [
[1,2,3,4],
[5,6,7,8],
[9,1,2,3],
[4,5,6,7]
]
Def matrix(matrix):
Original_len = len(matrix)
First, last = matrix[0], matrix[-1]
matrix.pop()
For index, y in enumerate(matrix):
If index == 0:
print(matrix[index])
matrix.popleft()
inner_matrix(0, matrix[:-1])
If index == original_len:
print(last)
inner_matrix(1, reverse(matrix))
@SonyaEick
Copy link
Author

after getting knee deep into this one i realized i could have done recursion. oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment