Ad
  • Custom User Avatar

    Very cool solution. There is an overflow for n = 31, but very clever indeed

  • Custom User Avatar

    I love the programming 101. Thank you!

    There is not any hint or clue indicates that the n will greater than 3e6. I have to use my imagination to find out what time(or space) complexity is really required for this problem.

    If it can't be described as confusing, I think the only word can be used here is - ridiculous.

  • Custom User Avatar

    For example, you want to calculate the sum of 1 to 100, you should not write:

    var sum=0
    for (var i=1;i<=100;i++) sum+=i
    return sum
    

    you only need write:

    return 100*101/2
    

    You need find out a formula ;-)

  • Custom User Avatar

    maybe you need an O(1) solution, the point of this kata is not calculate, is find a simple way to get the result.

  • Custom User Avatar

    My code can deal with game(500000) in 5s. It's not that slow for an O(n) implementation of Python.

    I know may be there is a way (or many ways) to optimize. But it's not the problem.

    I want know the RANGE OF DATA!

    If n is 10 or less, an O(n^2) solution is fine. If n is about 10000, an O(n) solution is enough. If n is greater than 1e7, an O(1) solution is necessary.

    I'm fully aware the rules of solving algorithm problems. I'm experienced.

    But I hate to rewrite to code again and again, because the the f* website hides the range of data.

    At the very beginning, I thought the largest n is 8!

    I'm really really depressed by what the problem I'm suffering here.

  • Custom User Avatar

    and in fact, this kata did not need more calcute but need more thinking ;-)

  • Custom User Avatar

    perhaps you can paste your code here(Mark as having spoiler content) and ask someone to help you ;-)

  • Custom User Avatar

    I implemented an O(n) solution with Python, but I got TLE. I really don't know why my code runs so slow, and of course, I have no idea about the upper bound of the input n.

    I'm depressed, by this problem, and by Codewars. I don't have enough information for solving the problem. I don't think it's a good idea to hide (or just ignore) the essential information for problem solving.

    Codewars is not a coder friendly online judge system. Let aside the confusing output format. (gosh)

    I'm confounded.

    I quit.