Ad
  • Default User Avatar

    Hi,
    I made similar solution, but instead of 'n' as number of rotation, I made n%data.lenght.
    As a beginner my question is- does pefrormance improve in that situation? Program does not to f.e 12004 rotations, but has to make a division and get rest of that.

  • Custom User Avatar

    testA are 100 random tests, sqrt is used but not directly when calculating m value in the control function, if it is so important in your code, you'll have to try another way.

  • Default User Avatar

    Thanks a lot! it will help me much.
    What about the testA case? Do you have any suggestion why is the solution of both sqrt the same?

  • Custom User Avatar

    Don't guess the input, print it: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#print-input and you'll have the exact input yourself, your guesses are wrong.

  • Default User Avatar

    Hey,
    I know that there is a lot of people who complited this in Java, but:
    I don't understand , why test have some results,namely:

    • test 14 - expected <-1> , but was <2>

      • in this situation it is most probably m=9, and you actually can build a tower of 2 cubes, 2x2x2 = 8 + 1x1x1 = 1 = 9 , so n should be 2.
    • test 15 - expected <-1> , but was <3>

      • in this situation it is most probably m=36, and you actually can build a tower of 3 cubes, 3x3x3 = 27 + 2x2x2==8 + 1x1x1 = 36 , so n should be 3.
    • testA - expected <-1> , but was <51156>

      • in this case it could be mistake of my algorithm - the problem is with precision of Java Calculator, or my methods that are using them to calculate sqrt.
        Namely:
        sqrt of 1712155883321112_517L is 1308493746,00000000000000000000 using big decimal sqrt
        sqrt of 1712155883321112_150L is 1308493746,00000000000000000000 using big decimal sqrt as well,
        As function sqrt is crucial in my solution, it has bad output. Maybe it is just lack of basic knowledge of mine.
  • Default User Avatar

    Thanks a lot for that! I am just starting Lambda impressions- this example showed me much :)