Sherlock and The Beast

  • + 0 comments

    The theory your running is close. I think you mis-explain it, given that you actually passed the test cases.

    modulo 1: 5 needs to be subtracted 9 times; modulo 2: 5 needs to be subtracted 3 times. Remember, 5 needs to appear a number of times divisible by 3. If the current number is divisible, and you remove 1 or 2, the resulting number can not mathematically be divisible by 3.

    You also need to add an additional check to make sure that you actually have enough 5s to remove the required number. If not, that should be the only case where you can not make a proper number, resulting in a "-1".