Browse Source

Solved Sherlock and the Beast

main
Titouan Rigoudy 11 years ago
parent
commit
7818adc9a1
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      sherlock_and_the_beast/sherlock_and_the_beast.py

+ 25
- 0
sherlock_and_the_beast/sherlock_and_the_beast.py View File

@ -0,0 +1,25 @@
#!/usr/bin/python3
# https://www.hackerrank.com/challenges/sherlock-and-the-beast
import sys
def largest_decent_number(num_digits):
if num_digits in [1,2,4,7]:
return '-1'
quot3, mod3 = divmod(num_digits, 3)
if mod3 == 0:
return '555' * quot3
elif mod3 == 1:
return '555' * (quot3 - 3) + '3333333333'
elif mod3 == 2:
return '555' * (quot3 - 1) + '33333'
def main():
num_tests = int(sys.stdin.readline())
for _ in range(num_tests):
print(largest_decent_number(int(sys.stdin.readline())))
if __name__ == '__main__':
main()

Loading…
Cancel
Save