Ad
  • Custom User Avatar

    Points for being different, but this solution doesn't work because binary OR is not the same as ADD for all inputs. This shows the importance of good testing code. I assume it passed the testing that was available at the time.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for this solution. I learned more about functional programming by studying it and getting a very nice piecewise explanation by Claude, the AI Chatbot. Since I'm not very familiar with this style, I tested this solution and found that it fails with a time-out at 12 seconds every time, which makes me wonder how it got on this list, except I'm glad it did. Buddy() is written to call sum(i) again if i<sum(i). If the sum(i) is saved and reused (oh no!), about 25% of the time is saved and the solution passes "ATTEMT" most of the time in 10-11.5 seconds. The solution with 12 or more votes for Best Practices, finishes in 2-3 seconds. Cheers.

  • Custom User Avatar

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

  • Custom User Avatar

    I had that thought too. But n has a fixed range and while m may be larger than the limit of the range, there are only a limited number of m's, one for one with the values of n.