Last active
December 16, 2022 22:12
-
-
Save SonyaEick/54e02808c8a8cf48ba77403def1f1e03 to your computer and use it in GitHub Desktop.
Nearly complete code challenge for an interview.
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
# 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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
after getting knee deep into this one i realized i could have done recursion. oh well.