Created
June 2, 2016 13:29
-
-
Save tanayag/8f8c7e5ea5c4b237a572f1dbde29fbc3 to your computer and use it in GitHub Desktop.
Sherlock and The Beast (Python 2) (Hackerrank)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| t = int(raw_input()) | |
| for t in range(0,t): | |
| n = int(raw_input()) | |
| if n<9: | |
| if n == 3: | |
| print('555') | |
| elif n==5: | |
| print('33333') | |
| elif n==6: | |
| print('555555') | |
| elif n==8: | |
| print('55533333') | |
| else: | |
| print('-1') | |
| else: | |
| if n%3 == 0: | |
| y = 0 | |
| x = n/3 | |
| print(('555'*x)+('33333')*y) | |
| elif n%3 == 1: | |
| y = 2 | |
| x = (n-10)/3 | |
| print(('555'*x) + ('33333')*y) | |
| elif n%3 == 2: | |
| y = 1 | |
| x = (n-5)/3 | |
| print(('555'*x)+('33333')*y) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment