Skip to content

Commit

Permalink
Solved Sherlock and the Beast
Browse files Browse the repository at this point in the history
  • Loading branch information
letitz committed Sep 27, 2014
1 parent 26ce808 commit 7818adc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sherlock_and_the_beast/sherlock_and_the_beast.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 7818adc

Please sign in to comment.