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
#Make use of the test cases, All test cases passed. Take a look at my git repo 'Py_Challenge_Accepted' | |
points = [[1,1],[3,4],[-1,0]] | |
#points = [[1,2],[2,2],[3,2],[0,-2],[4,3]] | |
#points = [[1,1],[3,4],[-1,0]] | |
#points = [[3,2],[-2,2]] | |
xDiff = yDiff = time = 0 | |
for i in range(len(points)-1): | |
xDiff = abs(points[i][0] - points[i+1][0]) | |
yDiff = abs(points[i][1] - points[i+1][1]) | |
time = time + max(xDiff, yDiff) |
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
from collections import deque | |
if __name__ == "__main__": | |
#This deque is used store the popped cube from the original array | |
vertical = deque() | |
for _ in range(int(input())): | |
#Number of cubes | |
height = int(input()) | |
#Side lenght of cubes | |
stack = deque(map(int, input().split())) |
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
""" | |
magic square is a n x n matrix of distinct positive integers from 1 to n^2. | |
where the sum of any row, column, or diagonal of length n is always equal to | |
the same number: the magic constant. | |
The magic square has been well studied in history, so the magic constant can | |
be calculated: Magic Constant (M) = n * ((n^2 + 1) / 2). | |
In this problem n will be 3, which means we now know the magic constant: |