From eafe872717e5cb82a8a71490aa83424e1ed22ed8 Mon Sep 17 00:00:00 2001 From: Anant Arun Date: Sat, 14 Aug 2021 12:26:42 +0530 Subject: [PATCH 1/4] Create ItertoolsCombination.py --- Python/ItertoolsCombination.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Python/ItertoolsCombination.py diff --git a/Python/ItertoolsCombination.py b/Python/ItertoolsCombination.py new file mode 100644 index 0000000..d92e433 --- /dev/null +++ b/Python/ItertoolsCombination.py @@ -0,0 +1,12 @@ +/* +Solution for Itertools.combination() +https://www.hackerrank.com/challenges/itertools-combinations/problem + */ +from itertools import combinations +x,y = input().split() +x = list(x) +x.sort() +for i in range(1,int(y)+1): + z = list(combinations(x,i)) + for j in z: + print(''.join(j)) From 9e034f1955089e91c7b56e31b1d1eeca10d1306d Mon Sep 17 00:00:00 2001 From: Anant Arun Date: Sat, 14 Aug 2021 12:28:20 +0530 Subject: [PATCH 2/4] Create SetOperations.py --- Python/SetOperations.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Python/SetOperations.py diff --git a/Python/SetOperations.py b/Python/SetOperations.py new file mode 100644 index 0000000..23f2e0d --- /dev/null +++ b/Python/SetOperations.py @@ -0,0 +1,22 @@ +/* +Solution For: Set .discard(), .remove() & .pop() +https://www.hackerrank.com/challenges/py-set-discard-remove-pop/problem +*/ + +n = int(input()) +s = set(map(int, input().split())) +noc = int(input()) +commands = { + "pop" : lambda a:a.pop(), + "remove" : lambda a,b:a.remove(b), + "discard" : lambda a,b : a.discard(b) +} +for i in range(noc): + z = input() + z1 = z.split() + command = z1[0] + try: + commands[command](s,int(z1[1])) + except IndexError: + commands[command](s) +print(sum(s)) From b548d60b31ca7255d44e26d78e56fed880525a30 Mon Sep 17 00:00:00 2001 From: Anant Arun Date: Sat, 14 Aug 2021 12:30:19 +0530 Subject: [PATCH 3/4] Create DesignerDoorMat.py --- Python/DesignerDoorMat.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Python/DesignerDoorMat.py diff --git a/Python/DesignerDoorMat.py b/Python/DesignerDoorMat.py new file mode 100644 index 0000000..fee713f --- /dev/null +++ b/Python/DesignerDoorMat.py @@ -0,0 +1,14 @@ +/* +Solution For: Desginer Door Mat +https://www.hackerrank.com/challenges/designer-door-mat/problem +*/ + +n,m = map(int,input().split()) +#Abovepart +for i in range(1,((n-1)//2)+1): + print(((2*i-1)*".|.").center(m,'-')) +#Middlepart +print("WELCOME".center(m,'-')) +#belowpart +for i in range(((n-1)//2),0,-1): + print(((2*i-1)*".|.").center(m,'-')) From 688454470ad0ed9476e1e1c54c549d36f81e3ce2 Mon Sep 17 00:00:00 2001 From: Anant Arun Date: Sat, 14 Aug 2021 12:32:26 +0530 Subject: [PATCH 4/4] Create CollectionsOrderedDict.py --- Python/CollectionsOrderedDict.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Python/CollectionsOrderedDict.py diff --git a/Python/CollectionsOrderedDict.py b/Python/CollectionsOrderedDict.py new file mode 100644 index 0000000..80e56a6 --- /dev/null +++ b/Python/CollectionsOrderedDict.py @@ -0,0 +1,18 @@ +/* +Solution For: collections.OrderedDict +https://www.hackerrank.com/challenges/py-collections-ordereddict/problem +*/ +from collections import OrderedDict +n = int(input()) +ordered_dictionary = OrderedDict({}) +for i in range(n): + x = input().split(' ') + y = int(x[-1]) + x.pop() + x1 = ' '.join(x) + if x1 in ordered_dictionary: + ordered_dictionary[x1] += y + else: + ordered_dictionary[x1] = y +for i,j in ordered_dictionary.items(): + print(i,j)