Ad
  • Custom User Avatar

    Also, I'm going to assume after looking at your profile that you need it in Ruby. :P Here ya go!

    def testing(actual, expected)
        Test.assert_equals(actual, expected)
    end
    
    Test.describe("wallpaper") do
        Test.it("Basic tests") do   
            testing(get_count(123),2)
            testing(get_count(1230),5)
            testing(get_count(1),0)
            testing(get_count(1111111111),25)
        end
    end
    
  • Custom User Avatar

    What language do you need the tests in? Also, it is true that (1111111111) results in 25. Your 10^2 thinking is clever, but it is incorrect. For example:

    1111111111/1 is divisible,
    1111111111/11 is divisible,
    BUT when you begin testing the 111's, you will realize that 1111111111/111 does not go in evenly. Same with the 1111's.

    So your 10^2 would be correct if you were looking for all consecutive combinations and not worrying about if they're divisible, but it is incorrect because we DO care about divisibility.