From 13daff21ef56e38adc1acd0f633fb83c709cd003 Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:02:51 +0530 Subject: [PATCH 1/7] Add files via upload --- catsdogs.py | 16 ++++++++++++++++ permut2.py | 22 ++++++++++++++++++++++ queue_2stacks.py | 35 +++++++++++++++++++++++++++++++++++ recipe.py | 22 ++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 catsdogs.py create mode 100644 permut2.py create mode 100644 queue_2stacks.py create mode 100644 recipe.py diff --git a/catsdogs.py b/catsdogs.py new file mode 100644 index 0000000..b927e5e --- /dev/null +++ b/catsdogs.py @@ -0,0 +1,16 @@ +t = int(input()); + +for _ in range(t): + c, d, l = map(int, input().split(' ')); + + max = 4*(d+c); + + if 2*d >= c: + min = 4*d; + else: + min = 4*d + (c - 2*d) * 4; + + if l in range(min, max+1, 4): + print("yes"); + else: + print("no"); \ No newline at end of file diff --git a/permut2.py b/permut2.py new file mode 100644 index 0000000..a39d815 --- /dev/null +++ b/permut2.py @@ -0,0 +1,22 @@ +while True: + # read input + n = int(input()) + if(n > 0): + + perm = [None]; + inv_perm = [None]*(n+1); + #print inv_perm;) + i = 1; + for num in map(int,raw_input().split()): + perm.append(num); + inv_perm[num] = i; + i += 1; + + if perm == inv_perm: + print "ambiguous"; + else: + print "not ambiguous"; + + else: + break; + diff --git a/queue_2stacks.py b/queue_2stacks.py new file mode 100644 index 0000000..fbd1bd1 --- /dev/null +++ b/queue_2stacks.py @@ -0,0 +1,35 @@ +# Program that implements queue using 2 stacks +# Problem statement: https://www.hackerrank.com/contests/pride-ab-filtering-test-3rd-years/challenges/queue-using-two-stacks +stack1 = []; +stack2 = []; + +def enqueue(item): + stack1.append(item); + +def dequeue(): + # if stack2 is empty, move all elements from stack1 to stack2 + if not len(stack2): + while len(stack1): + stack2.append(stack1.pop()); + # the topmost element of the stack2 will always contain the first element of the queue + return stack2.pop(); + +def display(): + # if stack2 is empty, then the bottom element of stack1 will be the first element in the queue + if len(stack2): + print(stack2[len(stack2)-1]); + else: + print(stack1[0]); + +t = int(input()); # no. of test cases + +i = 0; +while i < t: + query = list(map(int,input().split(' '))); + if query[0] == 1: + enqueue(query[1]); + elif query[0] == 2: + dequeue(); + else: + display(); + i += 1; \ No newline at end of file diff --git a/recipe.py b/recipe.py new file mode 100644 index 0000000..5b4bda5 --- /dev/null +++ b/recipe.py @@ -0,0 +1,22 @@ +def findGcd(m, n): + while(m != n): + if m > n: + m = m - n; + else: + n = n - m; + return m; + +t = int(input()); + +for i in range(0, t): + ing = list(map(int, input().split(' '))) + + n = ing[0]; + + gcd = ing[1]; + + for j in range(2, n+1): + gcd = findGcd(gcd, ing[j]); + + for j in range(1, n+1): + print(str(int(ing[j]/gcd)), end=' '); \ No newline at end of file From c911eb185da925646a587f0e7695ec89bf18e5f4 Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:03:36 +0530 Subject: [PATCH 2/7] Delete permut2.py --- permut2.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 permut2.py diff --git a/permut2.py b/permut2.py deleted file mode 100644 index a39d815..0000000 --- a/permut2.py +++ /dev/null @@ -1,22 +0,0 @@ -while True: - # read input - n = int(input()) - if(n > 0): - - perm = [None]; - inv_perm = [None]*(n+1); - #print inv_perm;) - i = 1; - for num in map(int,raw_input().split()): - perm.append(num); - inv_perm[num] = i; - i += 1; - - if perm == inv_perm: - print "ambiguous"; - else: - print "not ambiguous"; - - else: - break; - From 9459b176267979e65a32b7e2d8ab9cd9ac1c040c Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:03:49 +0530 Subject: [PATCH 3/7] Delete catsdogs.py --- catsdogs.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 catsdogs.py diff --git a/catsdogs.py b/catsdogs.py deleted file mode 100644 index b927e5e..0000000 --- a/catsdogs.py +++ /dev/null @@ -1,16 +0,0 @@ -t = int(input()); - -for _ in range(t): - c, d, l = map(int, input().split(' ')); - - max = 4*(d+c); - - if 2*d >= c: - min = 4*d; - else: - min = 4*d + (c - 2*d) * 4; - - if l in range(min, max+1, 4): - print("yes"); - else: - print("no"); \ No newline at end of file From e712e1ad2c714e92810eda3050bcb93fa0745445 Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:05:35 +0530 Subject: [PATCH 4/7] Delete queue_2stacks.py --- queue_2stacks.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 queue_2stacks.py diff --git a/queue_2stacks.py b/queue_2stacks.py deleted file mode 100644 index fbd1bd1..0000000 --- a/queue_2stacks.py +++ /dev/null @@ -1,35 +0,0 @@ -# Program that implements queue using 2 stacks -# Problem statement: https://www.hackerrank.com/contests/pride-ab-filtering-test-3rd-years/challenges/queue-using-two-stacks -stack1 = []; -stack2 = []; - -def enqueue(item): - stack1.append(item); - -def dequeue(): - # if stack2 is empty, move all elements from stack1 to stack2 - if not len(stack2): - while len(stack1): - stack2.append(stack1.pop()); - # the topmost element of the stack2 will always contain the first element of the queue - return stack2.pop(); - -def display(): - # if stack2 is empty, then the bottom element of stack1 will be the first element in the queue - if len(stack2): - print(stack2[len(stack2)-1]); - else: - print(stack1[0]); - -t = int(input()); # no. of test cases - -i = 0; -while i < t: - query = list(map(int,input().split(' '))); - if query[0] == 1: - enqueue(query[1]); - elif query[0] == 2: - dequeue(); - else: - display(); - i += 1; \ No newline at end of file From 69170fd9a794cf890ac51a8747e59de16398ed19 Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:05:48 +0530 Subject: [PATCH 5/7] Delete recipe.py --- recipe.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 recipe.py diff --git a/recipe.py b/recipe.py deleted file mode 100644 index 5b4bda5..0000000 --- a/recipe.py +++ /dev/null @@ -1,22 +0,0 @@ -def findGcd(m, n): - while(m != n): - if m > n: - m = m - n; - else: - n = n - m; - return m; - -t = int(input()); - -for i in range(0, t): - ing = list(map(int, input().split(' '))) - - n = ing[0]; - - gcd = ing[1]; - - for j in range(2, n+1): - gcd = findGcd(gcd, ing[j]); - - for j in range(1, n+1): - print(str(int(ing[j]/gcd)), end=' '); \ No newline at end of file From 044316c5bbaaa838e559d238a2f46bdf255d6f2e Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Mon, 4 Oct 2021 14:07:17 +0530 Subject: [PATCH 6/7] Add files via upload --- CodeChef/recipe.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 CodeChef/recipe.py diff --git a/CodeChef/recipe.py b/CodeChef/recipe.py new file mode 100644 index 0000000..5b4bda5 --- /dev/null +++ b/CodeChef/recipe.py @@ -0,0 +1,22 @@ +def findGcd(m, n): + while(m != n): + if m > n: + m = m - n; + else: + n = n - m; + return m; + +t = int(input()); + +for i in range(0, t): + ing = list(map(int, input().split(' '))) + + n = ing[0]; + + gcd = ing[1]; + + for j in range(2, n+1): + gcd = findGcd(gcd, ing[j]); + + for j in range(1, n+1): + print(str(int(ing[j]/gcd)), end=' '); \ No newline at end of file From a8e415b805e8521535e43b7b3134980a794e112d Mon Sep 17 00:00:00 2001 From: Sneha gupta Date: Fri, 22 Oct 2021 11:39:34 +0530 Subject: [PATCH 7/7] SQL Query --- HackerRank/sql project planning.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 HackerRank/sql project planning.txt diff --git a/HackerRank/sql project planning.txt b/HackerRank/sql project planning.txt new file mode 100644 index 0000000..d750bd6 --- /dev/null +++ b/HackerRank/sql project planning.txt @@ -0,0 +1,13 @@ +#https://www.hackerrank.com/challenges/sql-projects/problem + +SELECT Start_Date, MIN(End_Date) FROM + +(SELECT Start_Date FROM Projects WHERE Start_Date NOT IN (SELECT End_Date FROM Projects)) AS s, + +(SELECT End_Date FROM Projects WHERE End_Date NOT IN (SELECT Start_Date FROM Projects)) AS e + +WHERE Start_Date < End_Date + +GROUP BY Start_Date + +ORDER BY DATEDIFF(MIN(End_Date), Start_Date), Start_Date; \ No newline at end of file