Ad
  • Custom User Avatar
  • Custom User Avatar

    Difficulty is decided by the community in general, though there may be some outliers in terms of rankings rarely from time to time, this one is correctly ranked !

  • Custom User Avatar

    The user seems to be not active anymore.

    Also, this is an optimization task, and obviously a naive solution won't pass the tests.

  • Custom User Avatar

    If at first you don't succeed, think about the Math. If at second you don't succeed try another Kata, he literally has made almost a thousand of them.

  • Custom User Avatar

    If you always got timeout, please optimize your algorithm ;-)

  • Custom User Avatar

    As in many of myjinxin2015's katas, the key is to find out what the solution should be like so you're not actually bruteforcing the answer. Usually looking at the test cases will tell you if you need to avoid bruteforcing.

  • Custom User Avatar

    Okaaaaaaaaaay, my bad, I guess I didn't pay enough attention to the instructions '-'
    Will work on it properly then :D !

  • Custom User Avatar

    I'm using my eye to find the different ;-)
    first different: A[5] is 383, B[5] is 822
    second different: A[7] is 310, B[5] is 479
    third different:....
    Now I can say it should return false, because description said:

    Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements.

    You Don't need to sort the Array, I think ;-)

  • Custom User Avatar

    Hum, I'm not really sure bout it, but it looks like there's an issue with some random test. I used sort() and then compare each element, but like next, all the elements are the same, and it says expected false and got true
    Testing for:
    A = [859,367,200,535,908,383,102,310,233,575,325,58,262,119,56,492,589,903,576,508,462,494,48,885,627,724,683,353,689,690,601,174,140,17,806,460,281,431,324,735,55,323,583,930,97,731,807,769,719,272,188,53,6,756,700,698,822,61,514,67,363,737,602,726,769,533,670,333,43,479,625,877,37,314,278,572,102,431,754,803,924,481,594], B = [859,367,200,535,908,822,102,479,233,575,325,58,262,119,56,492,589,903,576,508,462,494,48,885,627,724,683,353,689,690,601,174,140,17,806,460,281,431,324,735,55,323,583,930,572,731,807,769,719,272,188,53,6,756,700,698,383,61,514,67,363,737,602,726,769,533,670,333,43,310,625,877,37,314,278,97,102,431,754,803,924,481,594]

    102 102 102 102 119 119 140 140 17 17 174 174 188 188 200 200 233 233 262 262 272 272 278 278 281 281 310 310 314 314 323 323 324 324 325 325 333 333 353 353 363 363 367 367 37 37 383 383 43 43 431 431 431 431 460 460 462 462 479 479 48 48 481 481 492 492 494 494 508 508 514 514 53 53 533 533 535 535 55 55 56 56 572 572 575 575 576 576 58 58 583 583 589 589 594 594 6 6 601 601 602 602 61 61 625 625 627 627 67 67 670 670 683 683 689 689 690 690 698 698 700 700 719 719 724 724 726 726 731 731 735 735 737 737 754 754 756 756 769 769 769 769 803 803 806 806 807 807 822 822 859 859 877 877 885 885 903 903 908 908 924 924 930 930 97 97

  • Custom User Avatar

    I'm getting a bit stuck on this one, I was wondering if there was any way to make my code lighter.
    It looks like my code is fine, but I always get the timeout even if I only got 1 for. Any tip?

  • Custom User Avatar

    It was a nice one, and I know I implemented it basically, but ain't it a bit too easy for a 7kyu kata?
    I'm pretty new to code wars, so I don't really know how the difficulty is set ^^