6 kyu

Lucas numbers

502 of 1,954NaMe613
Description
Loading description...
Algorithms
View
AllIssues9QuestionsSuggestions2Show Resolved
  • Please sign in or sign up to leave a comment.
  • mchist Avatar

    Please add support for the Rust language

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Angrax Avatar

    Input "-10" should be a positive Number... how? Same with "-30", there are some errors in the tests?! I got the same Numbers but negative - as in the instructions but can't complete this challenge.

  • ejini战神 Avatar

    C#: method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • RealKenshiro Avatar

    Please add range value for n in the description : 0 < n < 10000

  • JohanWiltink Avatar

    ( Java )

    • No performance requirements ( all top voted solutions are naive implementations! :S )
    • No random tests
  • FArekkusu Avatar

    Python 3 should be enabled.

  • clcraig Avatar

    @DarkD1, C++ expects a 64-bit long long result, but the model solution uses 32-bit int's for its calculations. This results in overflow errors for large values of n. I was using 64-bit variables for all calculations and failing to pass until I "downgraded" to 32-bit variables. The model solution should use long long for its calculations. Only the input parameter n should be int.

  • sazzadshopno Avatar

    C++ Translation

    Please review and approve.

  • markus.benko Avatar

    Could as well have been 8 kyu as there isn't any requirement for dynamic programming. (Java)

  • g964 Avatar

    Fine kata but Lucas numbers are kind of Fibonacci:-)

  • shb Avatar

    I am not able to submit python solution because i get below error. It does not work for one test which is lucasnumber(100).

    Process was terminated. It took longer than 6000ms to complete.

  • KreepN Avatar

    So the C# method declaration is as such:

    public static int lucasnum(int n) { }

    This defines it as return type of int, meaning it could only ever return values from (-2,147,483,648 to +2,147,483,647). In some of these comments I'm seeeing test cases that are for like -51, but at -45 the calc would be (-969,323,029 - 1,568,397,607 = -2,537,720,636). This would fall outside the acceptable range of an integer. As a result the calc goes wonky and returns some incorrect value.

    My code passes all the basic tests, but the random tests tell me it fails. I have all values of [n] calc'd for the allowable limit of the integer data type, so I'm not sure why it keeps telling me its failing.

  • bse Avatar

    Using Haskell I can get the tests running, but when submitting, I'm getting the following error:

     /tmp/haskell115713-20-1se0n8t/Codewars/Exercise/Lucas/Test.hs:26:36:
       Couldn't match expected type `Int' with actual type `Integer' In the first argument of `solution',
       namely `i' In the second argument of `shouldBe', namely `solution i' In the expression: lucasnum i `shouldBe` solution i
    
  • MarkNBroadhead Avatar

    My code passes tons of tests, including all those left below but when I submit my code I get the error: "Process was terminated. It took longer than 6000ms to complete" Can I not use recursion to solve this problem? Is it too computationally complex?

    I am also getting a lot of "submission timed out" errors.

  • Phanta Avatar

    The extension to negative integers is not fully explained in the instructions. Unless the "research" on external resources are part of the kata, these rules should be clearly explained.

  • jdivins Avatar

    Hi, I have tried the tests but I got failed message: -50 to -1 Expected: -45537549124, instead got: 28143753123 Test Passed: Value == 28143753123 Test Passed: Value == -17393796001 Test Passed: Value == 10749957122

    I have passed my own tests. Are these tests ok? Test.assertEquals(lucasnum(-51), -45537549124) Test.assertEquals(lucasnum(-50), 28143753123) Test.assertEquals(lucasnum(-49), -17393796001) Test.assertEquals(lucasnum(-48), 10749957122) Test.assertEquals(lucasnum(-47), -6643838879) Test.assertEquals(lucasnum(-46), 4106118243) Test.assertEquals(lucasnum(-45), -2537720636) Test.assertEquals(lucasnum(-44), 1568397607) Test.assertEquals(lucasnum(-43), -969323029) Test.assertEquals(lucasnum(-42), 599074578) Test.assertEquals(lucasnum(-41), -370248451) Test.assertEquals(lucasnum(-40), 228826127) Test.assertEquals(lucasnum(-39), -141422324) Test.assertEquals(lucasnum(-38), 87403803) Test.assertEquals(lucasnum(-37), -54018521) Test.assertEquals(lucasnum(-36), 33385282) Test.assertEquals(lucasnum(-35), -20633239) Test.assertEquals(lucasnum(-34), 12752043) Test.assertEquals(lucasnum(-33), -7881196) Test.assertEquals(lucasnum(-32), 4870847) Test.assertEquals(lucasnum(-31), -3010349) Test.assertEquals(lucasnum(-30), 1860498) Test.assertEquals(lucasnum(-29), -1149851) Test.assertEquals(lucasnum(-28), 710647) Test.assertEquals(lucasnum(-27), -439204) Test.assertEquals(lucasnum(-26), 271443) Test.assertEquals(lucasnum(-25), -167761) Test.assertEquals(lucasnum(-24), 103682) Test.assertEquals(lucasnum(-23), -64079) Test.assertEquals(lucasnum(-22), 39603) Test.assertEquals(lucasnum(-21), -24476) Test.assertEquals(lucasnum(-20), 15127) Test.assertEquals(lucasnum(-19), -9349) Test.assertEquals(lucasnum(-18), 5778) Test.assertEquals(lucasnum(-17), -3571) Test.assertEquals(lucasnum(-16), 2207) Test.assertEquals(lucasnum(-15), -1364) Test.assertEquals(lucasnum(-14), 843) Test.assertEquals(lucasnum(-13), -521) Test.assertEquals(lucasnum(-12), 322) Test.assertEquals(lucasnum(-11), -199) Test.assertEquals(lucasnum(-10), 123) Test.assertEquals(lucasnum(-9), -76) Test.assertEquals(lucasnum(-8), 47) Test.assertEquals(lucasnum(-7), -29) Test.assertEquals(lucasnum(-6), 18) Test.assertEquals(lucasnum(-5), -11) Test.assertEquals(lucasnum(-4), 7) Test.assertEquals(lucasnum(-3), -4) Test.assertEquals(lucasnum(-2), 3) Test.assertEquals(lucasnum(-1), -1)

  • Neoslide Avatar

    Hi,

    I try to solve it, but the test are not right ... Test.assertEquals(lucasnum(-10),123); // This test is not good. it should be lucasnum(-10) === -123 and not 123

    no ?

  • GiacomoSorbi Avatar

    I may be missing something, but I fear the random test cases in JS are not easily dealt with (not in a 6kyu kata, at least) big numbers, due to a lack of precision.

  • etherfreeze Avatar

    Solving this in Ruby: Recursion: passed tests, timed out on submit Memoization: passed tests, timed out on submit Math: passed tests, passed all submits except very high values (where I am assuming floating point becomes inaccurate)

    So basically, a challenging Kata (for me anyway :)) ... I'm tempted to look at the solutions but also want the satisfaction of solving this on my own. Any hints on the right direction? Is there an approach I am missing?

  • ChristianECooper Avatar

    This comment has been hidden.