Skip to content

Commit c5d56f7

Browse files
authored
Create sherlock-and-the-beast.py
1 parent 093ff8c commit c5d56f7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

sherlock-and-the-beast.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# https://www.hackerrank.com/challenges/sherlock-and-the-beast/problem
2+
3+
def decentNum(N):
4+
if N < 3:
5+
return [-1]
6+
if N % 3 == 0:
7+
return [5]*N
8+
for i in range(1,N+1):
9+
if (N-i)%3 ==0 and i%5 == 0:
10+
return [5]*(N-i)+[3]*i
11+
for i in range(1,N+1):
12+
if (N-i)%5 ==0 and i%3 == 0:
13+
return [3]*(N-i)+[5]*i
14+
return [-1]
15+
16+
17+
18+
if __name__ == '__main__':
19+
t = int(input().strip())
20+
for a0 in range(t):
21+
N = int(input().strip())
22+
print(*decentNum(N),sep='')

0 commit comments

Comments
 (0)