Skip to content

Commit 55df971

Browse files
committed
feat: Solved 12 Python domain problems
1 parent 24db20a commit 55df971

30 files changed

+331
-1
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/hackerrank.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT4
2+
from collections import defaultdict
3+
4+
groupASize, groupBSize = list(map(int, input().split()))
5+
6+
groupA = defaultdict(list)
7+
for i in range(1, groupASize + 1):
8+
groupA[input()].append(i)
9+
10+
groupB = list()
11+
for _ in range(0, groupBSize):
12+
groupB.append(input())
13+
14+
for element in groupB:
15+
results = groupA[element]
16+
17+
print(-1 if len(results) == 0 else " ".join(map(str, results)))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
from collections import Counter
3+
4+
profit = 0
5+
6+
nShoes = int(input())
7+
shoesSizes = Counter(input().split(' '))
8+
nClients = int(input())
9+
10+
for i in range(0, nClients):
11+
shoesSize, price = input().split(' ')
12+
amount = shoesSizes[shoesSize]
13+
14+
if amount > 0:
15+
profit += int(price)
16+
shoesSizes.update({shoesSize: -1})
17+
18+
print(profit)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
from collections import deque
3+
4+
nCmds = int(input())
5+
deque = deque()
6+
7+
for i in range(0, nCmds):
8+
cmd = input().split()
9+
10+
if cmd[0] == "append":
11+
deque.append(int(cmd[1]))
12+
13+
elif cmd[0] == "appendleft":
14+
deque.appendleft(int(cmd[1]))
15+
16+
elif cmd[0] == "pop":
17+
deque.pop()
18+
19+
elif cmd[0] == "popleft":
20+
deque.popleft()
21+
22+
print(" ".join([str(d) for d in deque]))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
from collections import namedtuple
3+
from functools import reduce
4+
5+
nStudents = int(input())
6+
colsName = input().split()
7+
Student = namedtuple('Student', ','.join(colsName))
8+
students = []
9+
10+
for i in range(0, nStudents):
11+
students.append(Student(*input().split()))
12+
13+
marks = list(map(int, [s.MARKS for s in students]))
14+
results = reduce(lambda a, b: a + b, marks) / len(students)
15+
16+
print(results)

0 commit comments

Comments
 (0)