Sherlock and The Beast

  • + 1 comment

    A few problems with this task 1) For n=15 both could work all 5 or all 3 but test just expect it to be all 5 2) 33333555 and 55533333 are valid solutions but again test expect it to be 55533333 3) for n = 100 there more then one solution it could be 10 times 5 and 90 times 3 but also could be 85 times 3 and 15 times 5

    All in all i've decided to not proceed because it doesn't make sense find all of the limitations that not descripbed in the Problem section.

    def decentNumber(n):
        for i in range(1,n//3+1):
            if (n - i*5) % 3 == 0:
                n5 = n - i*5
                n3 = n - n5
                return '5'*n5 + '3'*n3     
                
            if (n - i*3) % 5 == 0:
                n3 = n - i*3
                n5 = n - n3  
                # print('n3-n5', n3,n5)
                return '5'*n5 + '3'*n3
            
        return -1
    ``
    

    `