Skip to content

Instantly share code, notes, and snippets.

View kavilivishnu's full-sized avatar

Kavili Sri Vishnu Vardhan kavilivishnu

View GitHub Profile
@kavilivishnu
kavilivishnu / Code_practice.py
Created July 23, 2020 19:11
String Reverse and Swap case.
"""
Stack Data Structure
"""
class Stack:
def __init__(self):
self.number=[]
@kavilivishnu
kavilivishnu / Code_practice.py
Created July 26, 2020 08:29
A Recursive code which can be used for any filtering process.
'''
In the below code, I just took the modulo criteria for the filtering process.
if res = 0: The so and so person secured more than 80% or can be taken in any other aspect i.e. the work experience in so and so field.. etc etc.. aspects
if res = 1: >70%
if res = 2: >60%
Or the criterias can be taken the other way i.e. 0: 60% - 70%, 1: >=70% - 80%, 2: >80%
The criteria can be choosen based on changing the number than we're performin modulo operation with.
'''
Recursive Operation
'''
@kavilivishnu
kavilivishnu / Code_practice.py
Last active August 9, 2020 20:02
Minimize the sum of elements in an array
'''
The code below is to minimize the sum of all elements in an array. I have provided the time that the code is taking to execute too.
Miniize the sum was the question that was asked in a coding contest that I have recently participated in, and got to know that
it if a frequently asked question.
'''
import time
# The start time is not that useful in this program. But mentioned just incase
t1 = time.process_time()
a = [20, 7, 5, 4]
@kavilivishnu
kavilivishnu / Code_practice.py
Created August 27, 2020 19:23
Minimizing the sum of given input
'''
Minimise the sum
'''
import time
t1 = time.process_time()
a = []
for i in range(len(a)-1):
b = max(a)
c = b // 2
a.append(c)
@kavilivishnu
kavilivishnu / Code_practice.py
Last active August 27, 2020 19:30
Harlod and his homework from Goldman Sachs coding exam 2020
'''
Harlod and his homework
'''
money = [20, 54, 41]
deadline = [3, 4, 5]
money1 = [60, 40, 80]
deadline1 = [1, 2, 2]
lst = min(deadline)
res = list(filter(lambda i: i >= lst, deadline))
if res != 0:
@kavilivishnu
kavilivishnu / Code_practice.py
Created August 27, 2020 19:30
Swayamvara - Mockvita coding problem 2020
'''
Brides select their groom based on their priorities
'''
list1 = [1, 6, 18, 9, 2, 5, 6, 23, 565]
list2 = [16, 33, 4, 8, 13, 39, 54, 3, 1]
final = list(filter(lambda a: a % 1 == 0, list1))
final2 = list(filter(lambda a: a % 3 != 0, list2))
final3 = list(filter(lambda a: a % 3 == 0, list2))
@kavilivishnu
kavilivishnu / Code_practice.py
Created August 27, 2020 19:32
My own timer code using recursion (2 codes wit same structure but different output)
My own timer code using recursion (2 codes wit same structure but different output)
import time
def clock_1(i, j):
if i == 0 and j == 60:
return
else:
if i != 0 and j != 60:
clock_1(i - 1, j + 1)
time.sleep(1)
print(i, ":", j)