Skip to content

Commit f76c882

Browse files
authored
Added two new solved problems on hackerrank
1 parent be5598a commit f76c882

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
from itertools import combinations_with_replacement
9+
10+
# Complete the stones function below.
11+
def stones(n, a, b):
12+
arr = []
13+
perm = list(combinations_with_replacement([a, b], n-1))
14+
for i in perm:
15+
arr.append(sum(i))
16+
arr = list(set(arr))
17+
arr.sort()
18+
return arr
19+
20+
21+
if __name__ == '__main__':
22+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
23+
24+
T = int(input())
25+
26+
for T_itr in range(T):
27+
n = int(input())
28+
29+
a = int(input())
30+
31+
b = int(input())
32+
33+
result = stones(n, a, b)
34+
35+
fptr.write(' '.join(map(str, result)))
36+
fptr.write('\n')
37+
38+
fptr.close()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def minion_game(string):
2+
# your code goes here
3+
4+
vowels = ['A', 'E', 'I', 'O', 'U']
5+
kevin = 0
6+
stuart = 0
7+
for i in range(len(string)):
8+
if s[i] in vowels:
9+
kevin = kevin + (len(s)-i)
10+
else:
11+
stuart = stuart + (len(s)-i)
12+
13+
if stuart > kevin:
14+
print('Stuart '+ str(stuart))
15+
elif kevin > stuart:
16+
print('Kevin ' + str(kevin))
17+
else:
18+
print('Draw')
19+
20+
21+
if __name__ == '__main__':
22+
s = input()
23+
minion_game(s)

0 commit comments

Comments
 (0)