Skip to content

Instantly share code, notes, and snippets.

View BharathKumarS's full-sized avatar
:octocat:
Committed to constant learning

Bharath Kumar Shivakumar BharathKumarS

:octocat:
Committed to constant learning
View GitHub Profile
@BharathKumarS
BharathKumarS / Min_time_to_reach.py
Created March 4, 2020 04:09
LeetCode, Find the min time required to travel from start to end of the coordinates. Concept: list of list
#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)
@BharathKumarS
BharathKumarS / Plie_Cubes.py
Created March 3, 2020 04:47
HackerRank, Piling up! My most celebrated code of the week.
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()))
@grantfree035
grantfree035 / magic.py
Created November 28, 2018 07:17
Magic Matrix in Python 3
"""
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: