Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
for t in range(input()):
input()
lst = map(int, raw_input().split())
l = len(lst)
i = 0
while i < l - 1 and lst[i] >= lst[i+1]:
i += 1
while i < l - 1 and lst[i] <= lst[i+1]:
i += 1
print "Yes" if i == l - 1 else "No"
@abhinavkorpal
abhinavkorpal / common.py
Created April 7, 2017 09:55
Most Common
from collections import Counter, OrderedDict
class OrderedCounter(Counter, OrderedDict):
pass
[print(*c) for c in OrderedCounter(sorted(input())).most_common(3)]
if __name__ == '__main__':
N = int(raw_input())
arr = []
for i in range(N):
s = raw_input().split()
for i in range(1,len(s)):
s[i] = int(s[i])
if s[0] == "append":
arr.append(s[1])
if __name__ == '__main__':
n = raw_input()
print hash(tuple([int(i) for i in raw_input().split()]))
if __name__ == '__main__':
x, y, z, n = int(input()), int(input()), int(input()), int(input())
print ([[a,b,c] for a in range(0,x+1) for b in range(0,y+1) for c in range(0,z+1) if a + b + c != n ])
@abhinavkorpal
abhinavkorpal / largest_number.py
Created April 8, 2017 07:41
Find the Second Largest Number
if __name__ == '__main__':
n = int(raw_input())
arr = map(int, raw_input().split())
print sorted(list(set(arr)))[-2]
@abhinavkorpal
abhinavkorpal / nested_lists
Created April 8, 2017 07:50
Nested Lists
marksheet = []
for _ in range(0,int(input())):
marksheet.append([input(), float(input())])
second_highest = sorted(list(set([marks for name, marks in marksheet])))[1]
print('\n'.join([a for a,b in sorted(marksheet) if b == second_highest]))
@abhinavkorpal
abhinavkorpal / percentage.py
Created April 8, 2017 07:57
Finding the percentage
n = int(raw_input())
mydict = {}
for line in range(n):
info = raw_input().split(" ")
score = map(float, info[1:])
mydict[info[0]] = sum(score) / float(len(score))
print "%.2f" % round(mydict[raw_input()],2)
@abhinavkorpal
abhinavkorpal / swap.py
Created April 11, 2017 05:03
sWAP cASE
def swap_case(s):
return s.swapcase()
@abhinavkorpal
abhinavkorpal / split _and_join.py
Created April 11, 2017 05:20
String Split and Join
def split_and_join(line):
# write your code here
return("-".join(line.split()))