6 kyu

Tribonacci Sequence

61,893 of 160,816GiacomoSorbi
Description
Loading description...
Number Theory
Arrays
Lists
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Adamiscool123 Avatar

    Broo this is so hard how are we suppose to think like that???

  • lotheravanti Avatar

    Please update the Kata description so we don't all waste Attempts and screw up our stats:

    "be ready for anything else which is not clearly specified ;)"

    That's an understatement. When n is smaller than the signature array length, you did not specify the desired behavior. I had assumed it was the same expected as n == 0, an empty array. Instead, this is the response:

    "Testing for signature: [9.0, 15.0, 4.0] and n: 2 It should work with random inputs too: array lengths differed, expected.length=2 actual.length=0; arrays first differed at element [0]; expected:<9.0> but was:

    It clearly expects the the first 2 elements from signature array in this case.

  • HermTheWorm Avatar

    i did not understand what the assignment was.

    do you want the signature of a given list of the tribonnaci? it doesn't look like it since you give a signature as input in the function.

    I have no idea so sadly I had to look at the comments to understand.

  • 2xe Avatar

    Am I wrong in my assumption that "a signature array/list, returns the first n elements - signature included" should be 4 numbers and not 1? - yes i see the test assumes 1 but I dont see why that is correct?

  • KayleighWasTaken Avatar

    Input should not be provided as a sequence when it is of fixed size.

  • kikou4293 Avatar

    This comment has been hidden.

  • Benjamin-Re Avatar

    Liked it but I feel the description unnecesssarily verbose and confusing.

  • GregoryBlaze Avatar

    To anyone having trouble with this kata:

    1. Read the instructions carefully, and if you're confused about what a "fibonacci" is, google it.
    2. Stay motivated. This one's quite tough for a 6 kyu, but solving it was very rewarding for me.
    3. This kata requires lots of optimization, as it runs a whopping 4000 tests in the solution. Try to aviod putting too much logic in things like while loops in order to improve performance.
    4. Others have said it here, but make sure you remove all print statements before starting the final tests.

    You got this!

  • SacCno Avatar

    If you're having issues with the buffer when hitting "attempt" try removing any print statements you might have.

  • FerriteGiant Avatar

    On the C version, it only ran one test when I clicked "test" and only ran 2 tests when I clicked "Attempt"

  • Ghdhdhdh Avatar

    the question is phrased for a math student, not a cs student

  • arhont108 Avatar

    I've solved it and the solution is the same as the others. But the solution is not accepted. it took 12 seconds to execute and so it is not accepted

    i'm sad

  • drunkjedi Avatar

    maybe im bad, but all the answers (yours and mine) are same,and every of it marks as: 'None should equal [list]', in log everything is clear

  • AlishSafarli Avatar

    This comment has been hidden.

  • chokoladis Avatar

    This comment has been hidden.

  • Xros22 Avatar

    lots of energy focused here on the edge cases. it may be plodding, but i chose to handle those manually. life's too damn short :)

  • HIUNCY Avatar

    i have error when n = 3, i return back all 3 signature. am i wrong?

  • FishRun Avatar

    This comment has been hidden.

  • frewe Avatar

    This comment has been hidden.

  • Smrtypants Avatar

    The R version does not have sample tests

  • Cameron.storer Avatar

    Does anyone have any advice or hints to help me optimize my recursion?

  • AlexJarvis1210 Avatar

    This was a great Kata! Thanks for sharing it with us. As usual, my code spans several lines using if statements while this clever bunch are posting 2 liners :S

  • Davidentt Avatar

    This comment has been hidden.

  • JMC2002 Avatar

    So how should it pronouce in Italian?

  • yaroslavyatsyk Avatar

    This comment has been hidden.

  • arthurbacci Avatar

    Isn't it better to have the three numbers in use stored in the stack (long long a, b, c;) instead of acessing the array every time? Since it's malloc its access is slow, right?

  • bryl814 Avatar

    This comment has been hidden.

  • JonnyUtah Avatar

    This comment has been hidden.

  • WilliamSmithE Avatar

    I like this one :] Thank you for providing it.

  • MrBalbesina Avatar

    This comment has been hidden.

  • Akisuri Avatar

    signature = {8, 14, 18}

    n = 23

    Submitted: {8, 14, 18, 40, 72, 130, 242, 444, 816, 1502, 2762, 5080, 9344, 17186, 31610, 58140, 106936, 196686, 361762, 665384, 1223832, 2250978, 4140194}

    Expected: {9344, 17186, 31610, 58140, 106936, 196686, 361762, 665384, 1223832, 2250978, 4140194, 5080, 9344, 17186, 31610, 58140, 106936, 196686, 361762, 665384, 1223832, 2250978, 4140194}

    Test issue: The answer is supposed to be the same as submitted but somehow the test answer start element is not signature.

  • whuzar Avatar

    This comment has been hidden.

  • Lodka Avatar

    This comment has been hidden.

  • GreatMor Avatar

    all tests are successful, but when I click "ATTEMPT" I get this error Extended_tests Random_tests Expected: equal to [ 10 ] Actual: [ ]

  • gitumbra Avatar

    This comment has been hidden.

  • Medvekuk Avatar

    for c++ you also need to #include . Otherwise it will throw an error

  • yLaWy Avatar
  • anrukavina Avatar

    Hi, I'm trying to get the correct solution for this kata, and when I try to use the inputs that are used in the "Tests" tab, I get same exact results using my code, in the IDE.

    But, when I try to run the test here, I get the following error:

    " Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 135168 bytes) in /workspace/default/_solution.php on line 7 "

    Since I'm using the recursion for this kata, I guess I'm somehow running into the infinite loop, but shouldn't I get the same exact problem when running this code in my IDE? And also I think that infinite loop shouldn't happen in this case, because I've set the condition when to return the $signature array (more precisely $signature array should be returned when count of elements in array is same as the number of elements we've passed as argument to our function).

    Thanks in advance!

  • bulgakke Avatar

    This comment has been hidden.

  • Freemat Avatar

    My python code works in VSCode. On Codewars I get an Exit Code: 137, Max Buffer Size Reached (1.5 MiB). Removing the print() used for debug did the trick.

  • JelinPro Avatar

    so easy :)

  • Def3p Avatar

    fun level :))

  • GARCE Avatar

    am i not allowed to use global keyword in python cuzmy code does run on my device but here doesn't

  • ilvdrskn Avatar

    Hello everyone I ran into a problem: in the online compiler, js outputs everything as it should, but when I enter a solution, an error pops up, what is the problem?

  • Arc-Data Avatar

    What does it mean to be "deeply equal" in javascript though?

  • epicshaner Avatar

    One of my new favorite katas because of how satisfying the optimizations are. First I realized that I didn't have to check for an empty signature, and then I realized I could return my normal array even if the n was lower than 3, and now I'm trying to figure out how to avoid making an empty array then copying the signature into it which takes 2 lines. Very fun to work on this one!

  • michalis_efs Avatar

    in c# tests pass, but when I click attempt it gives me index out of bounds error, basically when index is 0 it says out of bounds for some reason

  • Szfaner Avatar

    Python I'm trying to test for n = 2 or 3 or 4 with the same lines like that for num in {1, 2, 3}.intersection({n}): return output.append(signature[num-1]) I expected return to be previous output (a list) appended with whatever number from signature indexed, but I'm getting 'None'. Why would list.append(int) return None?

  • SokolEvgen Avatar

    File "tests.py", line 13 test.assert_equals(tribonacci([0.5, 0.5, 0.5], 30), [0.5, 0.5, 0.5, 1.5.5, 4.5, 8.5, 15.5, 28.5, 52.5, 96.5, 177.5, 326.5, 600.5, 1104.5, 2031.5, 3736.5, 6872.5, 12640.5, 2 23249.5, 42762.5, 78652.5, 144664.5, 266079.5, 489396.5, 900140.5, 1655616.5, 3045153.5, 5600910.5, 10301680.5]) ^ SyntaxError: invalid syntax

    What the promlem with it? When I click "Test" that error, when 'Attempt', everything is fine..

  • brickEverything Avatar

    This comment has been hidden.

  • veles-II Avatar

    tests for JavaScript: ([3,2,1],10),[,6,93,2,1,16,31,56,103,190])

  • akar-0 Avatar
  • KayleighWasTaken Avatar
  • mitko17 Avatar

    Could be just me and it's not a big issue but... I think there's an extra semicolon in the Rust sample tests. I removed it and reset the Kana but it's still there.

    warning: unnecessary trailing semicolon
      --> src/lib.rs:25:289
       |
    25 | ...40.5, 1655616.5, 3045153.5, 5600910.5, 10301680.5]);;
       |                                                        ^ help: remove this semicolon
       |
       = note: `#[warn(redundant_semicolons)]` on by default
    
  • ccozens Avatar

    why does ([1,1,1],1) = 1? Its easy enough to code but I'm not getting the maths behind it. I assumed ([1,1,1],1) = 1+1+1 = 3 ?

  • XVIAccordsOfMadness Avatar

    More text, please

  • 4zr Avatar

    the problem said, it should return signature but why the heck they want [1] as return when actually [1,1,1] is given

  • MKTNL Avatar

    This comment has been hidden.

  • Tonyspec007 Avatar

    This comment has been hidden.

  • Daupu Avatar

    This comment has been hidden.

  • Vitya_Bober Avatar

    This comment has been hidden.

  • shubhampathak09 Avatar

    Nice fun kata

  • Neutrino666 Avatar

    My code Python is working fine for every test case except where n = 2, what i've understood from the description is that if n=2 and let signature = [a,b,c] so the program should return [a,b]. The problem is relevant for 16+ months.

    Test for checking n=2 does not work correctly. elif n == 2: return signature[:2]

  • Nagisanzenin Avatar

    Very fun and ease introduction to dynamic programming

  • PsiKai Avatar

    JavaScript folks-- slice or splice, and why?

  • Eallwealda Avatar

    This comment has been hidden.

  • Dachi13 Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • llpds Avatar

    This comment has been hidden.

  • Tooca_rev Avatar

    Only this kata doesn't work... Execution Timed Out Whole day i tried to attempt my solution but still the same

  • oword Avatar

    I believe this kata may have a bug, in the instructions it states "Signature will always contain 3 numbers", I was able to successfully pass every test except for these two: Expected: equal to [ 1, 2 ] Actual: [ 1, 2, 3 ] Expected: equal to [ 8, 7 ] Actual: [ 8, 7, 9 ]

    is this an issue with the problem?

  • __Andromache__ Avatar

    This comment has been hidden.

  • CrescentVisor Avatar

    This was nice.

  • sergiosja Avatar

    This comment has been hidden.

  • bixis Avatar

    This comment has been hidden.

  • Franky2594 Avatar

    This comment has been hidden.

  • Gumpsh Avatar

    Out of bounds when test size was 1 or 0, is this a programmer error or am I thinking about it the wrong way? (I used arrays)

  • Zumatra Hia Avatar

    This comment has been hidden.

  • andrewkarev Avatar

    Thank you!

  • Ahmed_Devil666 Avatar

    some time thay forget the most important thing in problem solving adding decent description and some example can any one know's why?

  • jpscholl Avatar

    My code passes the intial test, but fails saying that it's out of range. When testing the same input in Visual Studio, it works properly and I don't get the error.

  • radhikabhat431 Avatar

    I cleared all the tests but while submitting I get the crash error. I guess the caller function(in C) is supposed to free the Dynamically allocated array which is returned in the function. I assume that is why test is crashed along with this error. 'mumap_chunk(): invalid pointer' Can someone help me? How to solve this error?

  • CaffeineLife Avatar

    Ran into an error "Max Buffer Size Reached (1.5 MiB)" I don't know the reason that caused this but I think the random tests were too large to handle that it ran into an error or something. Explanations are much appreciated

  • Chriz7 Avatar

    This comment has been hidden.

  • 1spartacus9 Avatar

    I can't pass test on python. It works all fine, but last test with n = 425 fails. Comment: STDERR Max Buffer Size Reached (1.5 MiB)

    Would be great if someone could share some thoughts, how to outplay this :)

  • DanielaNik Avatar

    Okay just here to say that the "//hackonacci me" made my day.

  • Codaya007 Avatar

    This comment has been hidden.

  • vince555X Avatar

    when i click test it said pass and when i submit get error and it saying out bounce or length 0, in xbonnacii.

  • zgondal Avatar

    This comment has been hidden.

  • bkmz808 Avatar

    This comment has been hidden.

  • bogyi Avatar

    It is annoying that I can't pass because of this bug in Kotlin. Please fix it. It should work with random inputs too: arrays first differed at element [19]; expected:<532670.0267012811> but was:<532670.026701281>

  • Marakiil Avatar

    Hey, I do this kata in C and I think all thats failed with my code is the return value. This is the feedback: STDERR solution.c:22:9: warning: address of stack memory associated with local variable 'arr' returned [-Wreturn-stack-address] return arr;

    But I don't know how to return my Array where my values lie on a different way. Please help

  • Alpsboy-Jin Avatar

    Nice kata! First time using divide and conquer or similar...

  • Infuzibil Avatar

    This comment has been hidden.

  • Frodsham Avatar

    failing test in code wars but works in idle for case: test.assert_equals(tribonacci([1, 1, 1], 1), [1])

  • LG_2910 Avatar

    This comment has been hidden.

  • Johannnnn Avatar

    This is ridiculous. The solution is VERY easy. But somehow you have hidden expectancies. As we can't see what the basic tests are, I don't know what "I'm doing wrong". I 'll just skip this.

  • fernandonjardim Avatar

    Can't understand why 4010 tests. My first solution also worked fine on my local computer, but here, all the cases in which n=2 don't, so had to right similar code in another way.

  • mjpc815 Avatar

    This was a great problem. I learned about the Fibonacci sequence a while back, but this put a fresh spin on it.

  • seraphaanya Avatar

    This comment has been hidden.

  • VaJar97 Avatar

    This still doesn't work for Kotlin. Basic test Completed successfully, but random... expected:<956352.1708891367> but was:<956352.1708891368>

  • fingerzz Avatar

    This comment has been hidden.

  • Trinitui Avatar

    We do not need almost 4000 tests. I would suggest adding n = 1 and n = 2 tests into the basic tests so people can run into those edge cases in a more lenient environment.

  • duffymo Avatar

    My solution is "failing" a random test because the error of 3.725290298461914E-9 is less than the 1e-10 tolerance.

    Ridiculous.

  • Octaeon Avatar

    Pretty neat, but were 4000 tests really necessary? lol

  • Nickiris Avatar

    To long to understand the problem..

  • close2code-palm Avatar

    This comment has been hidden.

  • StoneEater Avatar

    Took some unnecessary extra steps here, still, nothing in intelectually more satisfactory than resolving a recursion problem.

  • jpchato Avatar

    Passing all tests but getting this error when I try to submit: "STDERR Max Buffer Size Reached (1.5 MiB)"

    Solving with Python, please assist

  • GeorgCantor Avatar

    This comment has been hidden.

  • kitlovescoding Avatar

    I submitted my code for Kotlin and failed the random tests. I see that a lot of other people have complained and the issue hasn't been fixed. At this point, I don't think the author is looking to fix the issue. I propose we remove Kotlin as a language for this Kata.

  • Jyothsna Binkam Avatar

    When I click on Test, it is passing all the tests. But when I click on Attempt, it is showing some errors. And the same code is working fine in my local editor. Please help me on this.

  • MauBocanegra Avatar

    This comment has been hidden.

  • codestar101 Avatar

    This comment has been hidden.

  • harsh579 Avatar

    my code is working fine for every test case except where n = 2, what i've understood from the description is that if n=2 and let signature = [a,b,c] so the program should return [a,b]. That's what my program is doing but it's wrong. Please someone correct me.

  • omar.fendri Avatar

    This comment has been hidden.

  • KobraKailus Avatar

    C++: tests have warnings and does not compile, anyone else?

  • lambolt Avatar

    This comment has been hidden.

  • Victory H Avatar

    4000 tests seems excessive

  • PythonHunter Avatar

    Wondering if anyone can help my output matches the test output (written in python) but keeps being failes see below: Testing for signature: [145, 188, 33] and n: 1 Log [1, 4, 5] this is the results from my code via a print statement an outputted to codewars consule

    It should work with random inputs too: [1, 4, 5] should equal [145]

  • CharlesOrly Avatar

    Any new programmers here? Hope you add me.

    P.S. my current language is JavaScript

  • CharlesOrly Avatar

    This comment has been hidden.

  • leCheveuCodeur Avatar

    Hello, tell me how do you validate an empty array in PHP? Because I can't do it with its different solutions:

    • array();
    • $array=[];
    • (array)$array;

    Except if there is an error in the verification... Thanks in advance !

  • tjabid Avatar

    Facing some precision issue with random numbers. Is this Kotlin issue?

    expected:<627093.059559724> but was:<627093.0595597238>

  • Veggiebob Avatar

    not really a fan of the n<3 case but I can see how that requires a more elegant solution

  • rsschool_1bfa10432f68ffd9 Avatar

    Hi, general qestion - How can I see exact results of my program execution, and not just failed check reports?

  • LionyxML Avatar

    It's a trap!

    Kata says: "Signature will always contain 3 numbers"

    Testing have signatures with even ONE number.

  • leothesouthafrican Avatar

    Python: Hi guys, although I have managed to get all the tests correct on my attempt, it doesn't let me pass the kata, all I know is that it is giving me an exit code of 137. Any help would be appreciated. Very new to codewars

  • CaptainLanghaar Avatar

    My code seems to pass all tests, but it crashes at some cases:

    Test Crashed Caught unexpected signal: 6

    Everytime I attemp it crashes at another case, it seems to be random. Any ideas?

  • treegem Avatar

    Still a Kotlin rounding Problem:

    It should work with random inputs too: arrays first differed at element [20]; expected:<765394.1346170895> but was:<765394.1346170896>

  • Itsuashi Avatar

    I think need to add in test section test that show what resoult should be if there's a input data like this: [1] , [1,1]. And better,but in this case Kata will be harder and longer, add what resoult should be on incorrect input data. Or create a new Kata with this tasks.

  • Mister-Zydeco Avatar

    I agree with an earlier poster. If you have cases where signature is somthing like [1,1], it is FALSE to claim that "signature is guaranteed to have at least 3 numbers." If you ask me to choose between believing that "guarantee" and my own lying eyes regarding the case of [1,1], I'm going to believe my own lying eyes and assert that [1, 1] has (at most!) two numbers. PLEASE accurately describe the rules on the input.

  • Nikede Avatar

    has bug in kotlin "It should work with random inputs too: arrays first differed at element [19]; expected:<684179.8255011056> but was:<684179.8255011055>"

  • SpLauT Avatar

    I was trying to do this one in Go.

    When I attempt to send in the result i get some random tests that fail. For example, this one:

    Tribonacci([3]float64{15, 7, 10}, 3)

    Gives:

    Expected <[]float64 | len:0, cap:0>: nil to equal <[]float64 | len:3, cap:4>: [15, 7, 10]

    This is really confusing to me.

  • jangelesg Avatar

    almost all my test passed however in the test Test.assert_equals(tribonacci([1, 1, 1], 1), [1]) failed is someone has the same issue any insigt would be aprecciate

    what is the logic behind this particular test?

  • Diongarman Avatar

    This comment has been hidden.

  • igorjoviano Avatar

    This comment has been hidden.

  • Vlad70 Avatar

    A bit unclear conditions in test examples. What output should be, if input ([0, 0, 1], 1) - [] or [1]? And what if n = 2?

  • semajpuos Avatar

    This comment has been hidden.

  • DavidJH Avatar

    I believe this kata has bugs in C. If I do nothing but return null I get 8 pages of errors starting with (note error is in fixture.c):

    fixture.c:24:29: warning: passing 'const long long *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] ASSERT_ARR_EQ(expected, submitted, n); ^~~~~~~~~ fixture.c:7:14: note: expanded from macro 'ASSERT_ARR_EQ' { free(submitted); submitted = NULL;
    ^~~~~~~~~ /usr/include/stdlib.h:563:25: note: passing argument to parameter '__ptr' here extern void free (void *__ptr) THROW; ^ fixture.c:24:5: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat] ASSERT_ARR_EQ(expected, submitted, n); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fixture.c:13:17: note: expanded from macro 'ASSERT_ARR_EQ' i, submitted[i], expected[i]);
    ^ /usr/include/criterion/internal/assert.h:529:62: note: expanded from macro 'cr_assert' #define cr_assert(...) CR_EXPAND(cr_assert
    (VA_ARGS)) ^~~~~~~~~~~ /usr/include/criterion/internal/assert.h:159:28: note: expanded from macro 'cr_assert
    ' CR_VA_TAIL(VA_ARGS)
    ^~~~~~~~~~~ note: (skipping 31 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) /usr/include/criterion/internal/preprocess.h:35:43: note: expanded from macro 'CR_EXPAND' #define CR_EXPAND(x) x ^

  • mateusap1 Avatar

    Why aren't the best solutions using recursion? Isn't better to solve this problem with recursion?

  • MiguelNevesF Avatar

    This comment has been hidden.

  • bhardwaj_sid Avatar

    This comment has been hidden.

  • SpIIIII Avatar

    This comment has been hidden.

  • aladeen_uthy Avatar

    This comment has been hidden.

  • MattYoung-UoY Avatar

    This comment has been hidden.

  • ruslan-smirnov Avatar

    This task have a broken cases with signature. Why i should be take {12, 0, 17}" and return empty array or when i take "{1, 1, 1}" and return 1. I should be return only Sequence not a single value.

  • OGsoundFX Avatar

    What does exit code: 139 mean ?

  • mwawrzkow Avatar

    I canno't post my result due to:

    main.cpp:78:31: warning: comparison of integers of different signs: 'std::vector::size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
          while (signature.size() < n)
                 ~~~~~~~~~~~~~~~~ ^ ~
    main.cpp:92:22: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
        for (short int i;i<40;++i)
                         ^
    main.cpp:92:21: note: initialize the variable 'i' to silence this warning
        for (short int i;i<40;++i)
                        ^
                         = 0
    2 warnings generated.
    
  • osamakawish Avatar

    "But what if we started with [0, 0, 1] as a signature? As starting with [0, 1] instead of [1, 1] basically shifts the common Fibonacci sequence by once place, you may be tempted to think that we would get the same sequence shifted by 2 places, but that is not the case and we would get: ..."

    This is a bit wrong here. The fibonacci sequence becoms a sequence of 0's when "shifted" by 2 places, since by definition, the sequence adds the previous two numbers, not previous three.

    Shifting sequence by 2 places gives us:

    1: 0 2: 0 3: (1) + (2) = 0 + 0 = 0 4: 0 5: ...

    I feel like an edit of the description is necessary.

  • iThx Avatar

    [Groovy] I think that exemplary solution has a mistake (variable memory overflow). Look at the negative numbers in the returned sol's array.

    assert Kata.tribonacci(sig, n) == sol(sig, n)
                |          |    |  |  |   |    |
                |          |    41 |  |   |    41
                |          |       |  |   [20, 0, 18]
                |          |       |  [20, 0, 18, 38, 56, 112, 206, 374, 692, 1272, 2338, 4302, 7912, 14552, 26766, 49230, 90548, 166544, 306322, 563414, 1036280, 1906016, 3505710, 6448006, 11859732, 21813448, 40121186, 73794366, 135729000, 249644552, 459167918, 844541470, 1553353940, -1437903968, 959991442, 1075441414, 597528888, -1662005552, 10964750, -1053511914, 1590414580]
                |          |       false
                |          [20, 0, 18]
                [20, 0, 18, 38, 56, 112, 206, 374, 692, 1272, 2338, 4302, 7912, 14552, 26766, 49230, 90548, 166544, 306322, 563414, 1036280, 1906016, 3505710, 6448006, 11859732, 21813448, 40121186, 73794366, 135729000, 249644552, 459167918, 844541470, 1553353940, 2857063328, 5254958738, 9665376006, 17777398072, 32697732816, 60140506894, 110615637782, 203453877492]
    
  • ovr-avalanche Avatar

    This comment has been hidden.

  • booniepepper Avatar

    Groovy sample tests are the "Example" tests. :)

  • Syyno Avatar

    Description says "Signature will always contain 3 numbers". But some tests has 1 or 2 values. Please, fix description/tests.

  • naughtnowwhen Avatar

    Hi, i solved with recursion. But then noticed all the highest rated solutions use iteration instead. I know recursion isn't as efficient, but i do like it.

    Is iteration so much more efficient that for this problem recursion is a bad solution? Are the differences that dramatic?

  • user5369590 Avatar

    This comment has been hidden.

  • Dk221 Avatar

    This comment has been hidden.

  • Root-Exec Avatar

    I'm working it in C... There are so many pointers and "unpacking" to test my result. I can't figure out how the Kata is requesting my returned result (I'm using *result).

    I also get errors thrown that I'm not sure what they correlate too. I put my code in Xcode and I'm getting the correct answers... I feel like I'm more fighting the Kata test than I am figuring out the problem/challenge and learning C. Maybe figuring out the test functions is part of the test?

  • user8436785 Avatar

    Dart, Factor, Groovy, Julia, R, Racket, and TypeScript translations.

  • lambor Avatar

    kotlin translation of the kata doesn't handle floating point comparisons well too.

  • ALowVerus Avatar

    This comment has been hidden.

  • gitikx Avatar

    Not easy, but very well

  • IsaacAMurray Avatar

    This comment has been hidden.

  • writter Avatar

    I like this Kata, however, there is one point that was rather confusing. It is stated that the function/method has to return an array "of the first n elements - signature included" of the parameter array s. Plus, it is guaranteed that the signature always contains 3 values. So how come that there are tests that expect arrays of length less than 3 (e.g. 1) as a return? It would be nice, if some one could clarify that for me.

  • hurdygurd Avatar

    This comment has been hidden.

  • agnaranjo Avatar

    This comment has been hidden.

  • SouLWorkeR Avatar

    I get this error: Response received but no data was written to STDOUT or STDERR. What does it mean? What do I need to do? My language is Python.

  • arifast Avatar

    Hi, I am new to C programming. Does anyone tend to get this error : "Incorrect value at index 0: 1 should equal 1" or even "Incorrect value at index 0: 18 should equal 18". How do i fix this?

  • jsalinasf Avatar

    I got scared at the beginning and lost some honor.... I came back and nailed it! Don't let this kata scare you by its name, it is totally doable.

  • ahmed kareem Avatar

    System.IndexOutOfRangeException : Index was outside the bounds of the array. i'm in c#

  • Menschenkindlein Avatar

    Thank you for the fun exercise! Rust translation of the kata doesn't handle floating point comparisons well. Usually, with the tests that include floating numbers, it is common to specify the precision with which they should be compared. However, I cannot see what this kata has to do with floating numbers. They don't add any value in comparison to integers, only technical problems.

  • yamil_7 Avatar

    I'm getting Response received but no data was written to STDOUT or STDERR. I tried the examples on the Python IDLE, and they worked just fine, but for some reason it's not working here.

  • cmaga Avatar

    how do i know if my solution attempt was succesful? I don't get compilation erros but I also have no clue if i did it correctly. I get exit code 139 and thats is literally it. Now I'm here and it says Train again or next Kata ....did i win????? what

  • Nikolite_Pro Avatar

    My code passes fixed tests, but when random test takes place, the test crashes with following error: Error in ./test: corrupted size vs. prev_size: 0x000000000138a070\.

    Sometimes I would get another error: Error in ./test: free(): invalid next size (normal): 0x00000000012550a0.

  • chill dude Avatar

    This comment has been hidden.

  • linov Avatar

    Not sure what the assertion logic is doing when I submit my solution for Kotlin. My last print statement before i return the DoubleArray is: Result: [1.2219787059623188, 7.958071682121853, 10.172098571448887, 19.35214895953306, 37.4823192131038, 67.00656674408575, 123.8410349167226, 228.32992087391216, 419.17752253472054, 771.3484783253552, 1418.855921733988, 2609.381922594064, 4799.5863226534075, 8827.82416698146, 16236.792412228931] then I get an error: It should work with random inputs too: arrays first differed at element [0]; expected:<1.2219787059623188> but was:<2609.381922594064> But as seen from the println, the first element is 1.2219787059623188 and only the twelfth element is 2609.381922594064

  • Timmä Avatar

    This comment has been hidden.

  • ksp1510 Avatar

    This comment has been hidden.

  • StevenDixonDev Avatar

    "Signature will always contain 3 numbers" This is a lie. Why would you state this and then use inputs that do not in fact contain 3 numbers? And on top of that the instruction do not specify what needs to be returned if the array is less than 3.

  • Jenny.GoFastGirl Avatar

    Just tried the C# version. Sample tests pass. Basic test failed (index out of range). Random tests passed. Copied my code into VS and it runs fine for my tests. Why index out of range? I didn't experience any issues with rounding. All the random tests worked fine.

  • sergey.dvoryadkin Avatar

    Facing exactly the same issue as JMrbl. Every time expected result is slightly different from my output. Seems like the problem with precision. Does anyone have any idea how to fix it?

    Example output: It should work with random inputs too: arrays first differed at element [33]; expected:<3.8325466338498983E9> but was:<3.832546633849898E9>

    Kotlin

  • taurtk Avatar

    This comment has been hidden.

  • Jesse  Avatar

    The description is not clear especially for those who speak English as second language !

  • DAVE FUCK Avatar

    This comment has been hidden.

  • user2464240 Avatar

    This comment has been hidden.

  • JMrbl Avatar

    What can we do there? xD

    "It should work with random inputs too: arrays first differed at element [20]; expected:<831540.5337225463> but was:<831540.5337225464>"

    Kotlin

  • ndegz Avatar

    This comment has been hidden.

  • giobalda Avatar

    In kotlin I see the following error "src/test/kotlin/fixture.kt:10:84: error: unresolved reference: Solution" after running any kind of test.

  • balazs_kis Avatar

    This comment has been hidden.

  • kzm Avatar

    This comment has been hidden.

  • Unnamed Avatar

    Sorry I haven't noticed until now.

    if n == 0, then return an empty array

    In C NULL is expected instead of an empty array and this case isn't tested at all.

  • Unnamed Avatar

    Rust has a better type system, so the type of signature should be &[f64; 3].

  • Unnamed Avatar

    Floats again... This time Rust:

    testing for signature [8.769541187420643, 1.5927735656792796, 6.5690450133106015] and n 8 Test Failed assertion failed: (left == right) left: [8.769541187420643, 1.5927735656792796, 6.5690450133106015, 16.931359766410523, 25.093178345400403, 48.593583125121526, 90.61812123693247, 164.3048827074544], right: [8.769541187420643, 1.5927735656792796, 6.5690450133106015, 16.931359766410523, 25.093178345400403, 48.593583125121526, 90.61812123693245, 164.3048827074544]

  • qwertyu123 Avatar

    @GiacomoSorbi

    Rust translation

    I am newbie here so I hope you'll help me if I'm doing something wrong

  • Unnamed Avatar

    C:

    incorrect value at index 30: 2.703799e+08 should equal 2.703799e+08

  • poszarp Avatar

    In Kotlin I can succesfully pass all sample tests, but I get into issues with rounding when running random tests. Can anyone explain what is the rounding rule used in this Kata?

  • melkiythegreat Avatar

    in plain C incorrect value at index 13: 64548.1 should equal 64548.1 incorrect value at index 4: 85.4 should equal 85.4 and so on

  • Unnamed Avatar

    Does every translation have to use that stupid float now? At least there should be proper comparisons. C:

    incorrect value at index 4: 61.9 should equal 61.9