Ad
  • Default User Avatar

    Yes,me too

  • Default User Avatar

    I like this one

  • Default User Avatar

    I ran some tests to try and find the best solution. I think I have found the best solution on this test so far. My solution is obviously not the best solution out there, but it does seem to run a bit faster. Here are my test results, running each function 10 million times:

    Starting test accounting...
    Test acounting has taken: S0 ns18847747
    Test accounting will be subtracted from actual test results

    Starting countByZero...
    countByZero has taken: 205182690933 NanoSeconds

    Starting countByOne...
    countByOne has taken: 177735822862 Nanoseconds

    Starting countByTwo...
    countByTwo has taken: 215657184532 Nanoseconds

    Starting countByThree...
    countByThree has taken: 234678624360 Nanoseconds

    Repo that holds the tests, you should test your own too!
    https://github.com/MicroBit512/countByTesting/tree/main

    Notes.
    I made the first three functions. I submitted the function called countByTwo. I named your function countByThree.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    No need to have the 2nd and 3rd import statements I believe.