Skip to content

Instantly share code, notes, and snippets.

View amulyakashyap09's full-sized avatar
🎯
Focusing

Amulya Kashyap amulyakashyap09

🎯
Focusing
  • Greater Noida
View GitHub Profile
@amulyakashyap09
amulyakashyap09 / mbr.js
Created May 18, 2017 18:45
can create all mongo databases backup && restore
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path').resolve('.');
exports.createBackup = function (credentials, options, callback) {
if ("dbName" in options && "path" in options) {
exec("pgrep mongod", function (err) {
if (err) {
@amulyakashyap09
amulyakashyap09 / leap_year.py
Created December 29, 2017 15:01
Function to check whether year is leap year or not | Hackerrank
def is_leap(year):
leap = True
if year%4 != 0 or (year%100 == 0 and year%400 != 0):
leap=False
return leap
@amulyakashyap09
amulyakashyap09 / print_n_times.py
Created December 30, 2017 06:35
Print N times in Same line | Hackerrank
if __name__ == '__main__':
n = int(input())
# print(*range(1, n+1))
for i in range(1, n+1):
print(i, end='')
@amulyakashyap09
amulyakashyap09 / print_all_possible_compbinations.py
Created December 30, 2017 20:48
Print all possible combinations | hackerrank
import sys
if __name__ == '__main__':
a = int(input())
b = int(input())
c = int(input())
n = int(input())
print([[x,y,z] for x in range(a + 1) for y in range(b + 1) for z in range(c + 1) if x + y + z != n])
@amulyakashyap09
amulyakashyap09 / second_lowest_values.py
Created December 31, 2017 12:21
Print second lowest values from nested lists | hackerrank
from operator import itemgetter
if __name__ == '__main__':
students=[]
lowest_score=0;
for _ in range(int(input())):
name = input()
score = float(input())
students.append([name, score])
#get minimum value of nested list
@amulyakashyap09
amulyakashyap09 / find_the_percentage.py
Created December 31, 2017 12:35
Find the percentage | Hackerrank
import math
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input()
@amulyakashyap09
amulyakashyap09 / strict_super_set.py
Created December 31, 2017 13:31
Check Strict Superset | hackerrank
ms = [int(x) for x in input().split()] #main_set (ms)
ms.sort()
n = int(input()) #no of sub/other lists
os=False
for i in range(n):
ss = [int(y) for y in input().split()] #taking other list as input
if len(ss) > 0 and len(ss) <= len(ms):
ss.sort()
os = set(ms).issuperset(set(ss))
print(os)
@amulyakashyap09
amulyakashyap09 / no_idea.py
Created December 31, 2017 15:24
No Idea!
(n, m) = map(int, input().split()) #take input in n , m
h=0;
a = map(int, input().split())#take array as input
A = set(map(int, input().split())) #take array as input and create SET
B = set(map(int, input().split()))#take array as input and create SET
for el in a:
if el in A:
h += 1
elif el in B:
h -= 1
@amulyakashyap09
amulyakashyap09 / distinct_list.py
Last active December 31, 2017 15:43
Set .add() | hackerrank
# METHOD 1
n = int(input())#take input in n
a = set()
for i in range(n):
ci = input()
if ci not in a:
a.add(ci)
print(len(a))
# METHOD 2
@amulyakashyap09
amulyakashyap09 / remove_discard_pop.py
Created December 31, 2017 16:23
Set remove, discard, pop problem | hackerrank
n = int(input())
s = set(map(int, input().split()))
o = int(input())
for i in range(o):
op = input().split()
if(op[0] == "pop"):
if len(s)>0:
s.pop()
elif(op[0] == "remove"):