Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2b48e5

Browse files
HackerRank....
1 parent d9f9111 commit f2b48e5

File tree

11 files changed

+257
-0
lines changed

11 files changed

+257
-0
lines changed

‎Hackerrank-Python3/Untitled.png

34.5 KB
Loading[フレーム]

‎Hackerrank-Python3/doormat.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''
2+
Size: 7 x 21
3+
---------.|.---------
4+
------.|..|..|.------
5+
---.|..|..|..|..|.---
6+
-------WELCOME-------
7+
---.|..|..|..|..|.---
8+
------.|..|..|.------
9+
---------.|.---------
10+
'''

‎Hackerrank-Python3/dot_cross.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Output Format
2+
3+
# Print the matrix multiplication of A and B .
4+
5+
# Sample Input
6+
7+
# 2
8+
# 1 2
9+
# 3 4
10+
# 1 2
11+
# 3 4
12+
# Sample Output
13+
14+
# [[7 10]
15+
# [15 22]]
16+
17+
import numpy
18+
n = int(input())
19+
a = []
20+
b = []
21+
l = list()
22+
for x in range(n):
23+
l = input()
24+
l = [int(i) for i in l.split(" ")]
25+
a.append(l)
26+
27+
for x in range(n):
28+
l = input()
29+
l = [int(i) for i in l.split(" ")]
30+
b.append(l)
31+
32+
print(numpy.dot(a, b))
33+

‎Hackerrank-Python3/finding_percent.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if __name__ == '__main__':
2+
n = int(input())
3+
student_marks = {}
4+
for _ in range(n):
5+
name, *line = input().split()
6+
scores = list(map(float, line))
7+
student_marks[name] = scores
8+
query_name = input()
9+
s = sum(student_marks[query_name])
10+
print("%.2f" % (s/3))

‎Hackerrank-Python3/inner_outer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import numpy
2+
A = numpy.array([int(x) for x in input().split(" ")])
3+
B = numpy.array([int(x) for x in input().split(" ")])
4+
print(numpy.inner(A, B))
5+
print(numpy.outer(A, B))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# list comprehensive
2+
3+
x = int(input())
4+
y = int(input())
5+
z = int(input())
6+
n = int(input())
7+
8+
print([[i, j, k] for i in range(x + 1) for j in range(y + 1)
9+
for k in range(z+1) if ((i + j+k) != n)])

‎Hackerrank-Python3/mean_varr_std.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Output Format
2+
3+
# First, print the mean.
4+
# Second, print the var.
5+
# Third, print the std.
6+
7+
# Sample Input
8+
9+
# 2 2
10+
# 1 2
11+
# 3 4
12+
# Sample Output
13+
14+
# [1.5 3.5]
15+
# [1. 1.]
16+
# 1.11803398875
17+
18+
import numpy
19+
n, m = input().split()
20+
n = int(n)
21+
m = int(m)
22+
l = list()
23+
arr = list()
24+
arr = []
25+
x = 0
26+
i = 0
27+
for x in range(n):
28+
l = input()
29+
l = [int(y) for y in l.split(" ")]
30+
arr.append(l)
31+
#print(arr)
32+
numpy.set_printoptions(legacy='1.13')
33+
# np.arr().astype(np.int)
34+
print(numpy.mean(arr, axis=1))
35+
print(numpy.var(arr, axis=0))
36+
print(numpy.std(arr, axis=None))
37+
38+
39+
#read about the function set_printoptions

‎Hackerrank-Python3/nested_list.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
if __name__ == '__main__':
2+
d = {}
3+
for _ in range(int(input())):
4+
name = input()
5+
score = float(input())
6+
d[name] = score
7+
s = sorted(d.items(), key=lambda x: x[1], reverse=False)
8+
t = s[0][1]
9+
# print(t)
10+
for x in s:
11+
if x[1] > t:
12+
t = x[1]
13+
break
14+
newdic = {}
15+
for x in s:
16+
if (t == x[1]):
17+
newdic[x[0]] = x[1]
18+
#print(x[0], x[1])
19+
ls = sorted(newdic.keys())
20+
for x in ls:
21+
print(x)
22+
23+
'''
24+
it's a mind boggling :) )p
25+
'''

‎Hackerrank-Python3/string_validator.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# In the first line,print True if has any alphanumeric characters.Otherwise, print False.
2+
# In the second line, print True if has any alphabetical characters.Otherwise, print False.
3+
# In the third line, print True if has any digits.Otherwise, print False.
4+
# In the fourth line, print True if has any lowercase characters.Otherwise, print False.
5+
# In the fifth line, print True if has any uppercase characters.Otherwise, print False.
6+
7+
8+
if __name__ == '__main__':
9+
s = input()
10+
for x in range(len(s)):
11+
if s[x].isalnum():
12+
print(True)
13+
break
14+
else:
15+
print(False)
16+
17+
for x in range(len(s)):
18+
if s[x].isalpha():
19+
print(True)
20+
break
21+
else:
22+
print(False)
23+
24+
for x in range(len(s)):
25+
if s[x].isdigit():
26+
print(True)
27+
break
28+
else:
29+
print(False)
30+
31+
for x in range(len(s)):
32+
if s[x].islower():
33+
print(True)
34+
break
35+
else:
36+
print(False)
37+
38+
for x in range(len(s)):
39+
if s[x].isupper():
40+
print(True)
41+
break
42+
43+
else:
44+
print(False)

‎Hackerrank-Python3/test_warp.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Sample Input 0
2+
3+
# ABCDEFGHIJKLIMNOQRSTUVWXYZ
4+
# 4
5+
# Sample Output 0
6+
7+
# ABCD
8+
# EFGH
9+
# IJKL
10+
# IMNO
11+
# QRST
12+
# UVWX
13+
# YZ
14+
15+
import textwrap
16+
17+
18+
def wrap(string, max_width):
19+
string = (textwrap.wrap(string, max_width))
20+
s = ""
21+
for x in string:
22+
s += x + '\n'
23+
s = s[:len(s)-1]
24+
return s
25+
26+
27+
if __name__ == '__main__':
28+
string, max_width = input(), int(input())
29+
result = wrap(string, max_width)
30+
print(result)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /