Ad
  • Custom User Avatar

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

  • Default User Avatar

    "calculate the times of the operations apply to the sequence"
    Can that be rephrased? It seems unclear.

  • Custom User Avatar

    That's it.

  • Custom User Avatar

    Resolved. Added sample explanation. Also fixed a typo.

    Thanks for your contribution!

  • Default User Avatar

    I agree that it was quite difficult to understand. It only really made sense to me once I looked up chords in circles on wikipedia.
    Other that, I like the approach of this kata, to not force me to use a specific algorithm, but instead throw this equation at me and let me decide how I want to solve it.

  • Default User Avatar

    the same formula

    I think there's no analytical solution, so these are performance tests. I haven't solved it yet thought, so I'm not sure.

  • Default User Avatar

    The drawing looks correct, the angle in question is AOB, which matches the second sample test. I'm not sure about the proper terms, "cental angle" seems to be more common, but there are many results for "center angle".

  • Custom User Avatar

    Please, explain clearly what you mean by "a chord diving a circle into two parts" and "center angle of the chord". From what I could understand, we have something similar to the plot in the image below where the angle between AB and OC can always be 90 degrees regardless of the 1 / X ratio, and I don't think that is the thing that you're implying.

  • Custom User Avatar

    Ah, X is not limited to integers, so there's more than 1000 possible inputs. Although, I don't see the point in testing those considering the same formula should work both for integral and non-integral X.

  • Custom User Avatar

    Constraints: 1 <= X <= 10^3

    Test Cases: 3*10^6 random tests

    3,000,000 tests for 1,000 inputs? Seriously?

  • Default User Avatar

    Random tests are not strong enough. This solution should be invalidated.

  • Custom User Avatar

    Sorry, I hardly go to Codewars.

    Your solution is incorrect. The numbers are very large and your solution may recurs v*n times. So your program will get a stack overflow.

    The time complexity of the solution is O(n log n). Think more!

  • Default User Avatar

    I get a StackOverflow in the random test.

    initialize(162885419, 466186498, 933872258, 811629502, 667992515, 432551576, 949205876, 704853680, 3422664, 141706686, 604045423, 244765318, 842862197, 947000759, 36365049, 315647101, 375917747, 26944337, 902471987, 606495393, 530330727, 723920507, 970890042, 752176407, 811407105, 781601923, 117874764, 494150506, 978209469, 702343375, 317081043, 415914823, 814885566, 445607882, 500588452, 955985133, 759973185, 123922063, 268153680, 531735000, 291317065, 961067781, 894284457, 942120463, 539817027, 554818622, 475090536, 865931848, 283891628, 365487471, 627595769, 454987982, 815429371, 663018417, 435650369, 845510893, 879695638, 761182434, 11241288, 816335587, 131292454, 254352906, 82389169, 741217628, 320072976, 605641144, 888816617, 712750506, 779278564, 23206248, 187100188, 76716475, 668364297, 399325018, 497684368, 456777931, 81939279, 923641990, 379212682, 134263919, 572910917, 195978614, 63490082, 148818629, 527030061, 165066701, 888761999, 603116397, 628244953, 963686664, 99967413, 734659925, 859072940, 61212173, 512097847, 207019786, 251668531, 571320403, 436334794, 922653825);
    modify(18, 131398922);
    UndefinedBehaviorSanitizer:DEADLYSIGNAL
    ==1==ERROR: UndefinedBehaviorSanitizer: stack-overflow on address 0x7ffda174efe8 (pc 0x7f0d7b15530e bp 0xffffffffffffff68 sp 0x7ffda174efe0 T1)
    ==1==WARNING: invalid path to external symbolizer!
    ==1==WARNING: Failed to use and restart external symbolizer!
    
  • Custom User Avatar

    Fixed. Thanks.

  • Custom User Avatar
    main.cpp:22:23: error: use of undeclared identifier 'len'
          for (; index <= len; index += (index & -index))
                          ^
    1 error generated.
    
  • Loading more items...