5 kyu

Common Denominators

1,725 of 15,271g964
Description
Loading description...
Fundamentals
Algorithms
Mathematics
  • Please sign in or sign up to leave a comment.
  • 今日微凉 Avatar

    Basic tests for python are wrong. These two and their suggested answers are wrong: [[18, 126], [42, 126], [10, 126]] should equal [[24, 84], [28, 84], [7, 84]]

    [[1, 1], [1, 1], [1, 1], [1, 1]] should equal [[1, 1], [3, 1], [4, 1], [5, 1]]

  • wayfar8r Avatar

    haven't paid attention at the last note in rust description and stucked awhile

  • fluke030 Avatar

    This comment has been hidden.

  • colinmcnicholl Avatar

    how do I find out what the inputs were for a failed test? I have submitted a solution in C++ for 'common denominators' and have failed test 3 with output: Expected: equal to "(77033412951888085,14949283383840498)(117787497858828,14949283383840498)(2526695441399712,14949283383840498)" Actual: "(3414707982693751,14949283383840498)(1573009032312,14949283383840498)(1612068318217,14949283383840498)"

  • JonathanGRiego02 Avatar

    This comment has been hidden.

  • JonathanGRiego02 Avatar

    For the test on java with the values {69, 130}, {87, 1310}, {30, 40} my answer is correct:

    Expected :(18078,34060)(2262,34060)(25545,34060) Actual :(36156,68120)(4524,68120)(51090,68120)

  • trashy_incel Avatar

    C fork

    • proper usage of the test framework
    • better assertion messages
    • better datatypes (const-qualifies the input + gets rid of the pointer-to-array notation by using a typedef)
    • initial code does not crash anymore
    • it is explained what kind of pointer to return
    • backwards-compatible
  • unjust Avatar

    Basic test case has a bug. In the Typescript challenge 60 is not a multiple of 9

    convertFrac([[1, 2], [4, 5], [3, 4], [6, 9], [7, 10]]), "(30,60)(48,60)(45,60)(40,60)(42,60)"

  • ErickRoot Avatar

    I can work it out in IntelliJ, but for some reason it did not work in this test. So why can't ChatGpt solve it?

  • zetterus Avatar

    i dont get it, how, HOW FOR THE GOD SAKE???

    [[12, 84], [28, 84], [7, 84]] should equal [[24, 84], [28, 84], [7, 84]]

    [[2, 2], [2, 2], [2, 2], [2, 2]] should equal [[1, 1], [3, 1], [4, 1], [5, 1]]

    Why in first case first numenator 24? All denumenators are already equal, so numenators shouldn't increase. Second is confusing too. Why numenators rising if denumenator again is equal? 0_0

  • fabriciomgomes Avatar

    This comment has been hidden.

  • saladmaker Avatar

    This comment has been hidden.

  • vkavsek Avatar

    rust has wrong tests: least common multiple of 1300, 1310 and 40 is 340_600 and NOT 34_060!

  • flyaway2525 Avatar
        lst = [ [1, 2], [4, 5], [3, 4], [6, 9], [7, 10] ];
        testing(lst, "(30,60)(48,60)(45,60)(40,60)(42,60)");
    

    If my calculation is correct, then this test case is wrong.
    Random patterns also passed, but only this pattern did not go well.

    The calculation result should be here.

        "(180,360)(288,360)(270,360)(240,360)(252,360)"
    
  • ejini战神 Avatar

    C#:

    • No random tests

    • Method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • nalEd Avatar

    does not pass the test of the correct application that was tested in the Visual Studio environment

  • ignaciocervino Avatar

    My output its the same as the test case but it says its failing. My output: [(18078, 34060), (2262, 34060), (25545, 34060)] test case failing XCTAssertTrue failed - should return [(18078, 34060), (2262, 34060), (25545, 34060)]

  • bdc0409 Avatar

    So, I don't really know why but in python I'm failing the final test. I believe it has something to do with the numbers being too large. I noticed that user "tatayo" had the EXACT same issue as I am 5 months ago. I don't believe the test is flawed, I just would love some help understanding how to fix it. Python was originally trying to convert the number into scientific notation and for that reason I believe, it is losing the precision of that last digit as it goes from 5 to 0. As far as I understood, python should be able to handle arbitrarily large integers in 3.0+ but, I I would love for someone to look at my solution and see if they could help out. (I had to hard code adding 5 to that value to be able to complete the kata.)

  • PythonEnjoyer Avatar

    This comment has been hidden.

  • expoodo Avatar

    Can anyone tell me what im suppose to return on the C version? it says long long (*convertFrac(long long lst[][2], int row))[2] {...} and in the sample tests the variable that holds the convertFrac result is just a pointer to a single dimensional array

  • Cloud Walker Avatar

    JavaScript. Example tests? lol shouldn't there be more than 1? This is the only one I see

    var lst = [ [1, 2], [1, 3], [1, 4] ]; 
    

    and they are all irreducible.

  • manstolethefruit Avatar

    This was too difficult to be 5 kyu. should've been above 3

  • aliaksandr-batskalevich Avatar

    Nice kata to remember math. Thanks!!!

  • enricodallastella Avatar

    Basic tests are wrong. it says that 34060 is a multiple of 40 and it is not...

  • tatayo Avatar

    I'm getting this message from the basic test on the python version, I believe it is wrong.

    [[77033412951888080, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

  • ANamelessSystem Avatar

    I spent a whole day to deal with it and found its biggest challenge for me was the math part. If you're a language beginner as me, I recommand you keep it for future.

  • Intothevoid Avatar

    Legendary kata!!!the guy who made this kata is pure code god.

  • Chario502 Avatar

    Great Kata Really Enjoyed It! not as hard as I thought it would be.

  • Tokkozhin Avatar

    I think I found another one issue: "expected '(4440,8325)(525,8325)(1332,8325)' to equal '(1480,2775)(175,2775)(444,2775)'"

  • Iurchenko Sergei Avatar

    I have spent about 14 hours on this kata. Am I alone?)

  • morrae Avatar

    np.lcm.reduce([i[1] for i in lst]) numpy.core._exceptions._UFuncNoLoopError: ufunc 'lcm' did not contain a loop with signature matching types (None, <class 'numpy.dtype[float64]'>) -> None

    Python. I am not getting this error in my IDE.

    If I write it as np.lcm.reduce([2. 3, 4]) it works perfectly. I believe there's an issue of some kind. How does it work for given list and not working with simplest list comprehension?

  • jrs80 Avatar

    This comment has been hidden.

  • GGor Avatar

    you must either accept ONLY THE SMALLEST denominator or ANY, you can't just expect us to gess the level of fraction simplification that's required for a given test.

  • Kutty44 Avatar

    What should I return if the input is empty? I couldn't figure it out. Test 3 fails and says nothing about input or expected output.

  • jdsteinhauser Avatar

    If I look at the second test data sample provided in the Elixir version: lst = [ [690, 1300], [87, 1310], [30, 40] ] testing(lst, [ [18078, 34060], [2262, 34060], [25545, 34060] ])

    The GCD of 34060 is incorrect. 34060 / 1300 = 26.2, 34060 / 1310 = 26, and 34060 / 40 = 851.5. I did all the prime factorization by hand, checked my algorithm for LCM, as well as verifying with other sources, and the correct GCD should be 340600.

  • paoloferrariapple Avatar

    (writing in swift) I think i have an issue but it's probably just me being stupid, when i try the code in Xcode it works wonders, when i run it on CW i get every number multiplied by 10 and i literally have no instruction that does that;

    not here for the solution obviously, just to know if it's a me dumb dumb problem or a known one

    this is the result of 1 test in CW and only 1 command print(), the same test on Xcode gives only the first line:
    test: [(69, 130), (87, 1310), (3, 4)] output: [(18078, 34060), (2262, 34060), (25545, 34060)]
    test: [(690, 1300), (87, 1310), (30, 40)] output: [(180780, 340600), (22620, 340600), (255450, 340600)]

  • Esed Avatar

    This comment has been hidden.

  • Jrsaldanha Avatar

    I didnt even understand the question..!

  • JoshTRN Avatar

    This comment has been hidden.

  • Sightstone Avatar

    I think my solution sometimes fails because the fractions are not simplified. But why does that even make a difference? Shouldn't it also work with unsimplified fractions?

  • Vadim_72 Avatar

    This comment has been hidden.

  • jschpp Avatar

    There needs to be a clue that the input can be empty.

  • akar-0 Avatar

    This comment has been hidden.

  • extremer220 Avatar

    One of the tests is:

    assert.strictEqual(
      convertFrac([[1, 2], [4, 5], [3, 4], [6, 9], [7, 10]]),
      "(30,60)(48,60)(45,60)(40,60)(42,60)"
    );
    

    But 60 is not divisible by 9 so the answer should be (90,180)(144,180)(135,180)(120,180)(126,180)

  • eJoest Avatar

    Like Muhamor, I'm wondering why the second of the "basic tests" (kotlin version) should have a least common denominator of 34060. 40 does not go into that evenly. Shouldn't it be 68120?

  • user6800471 Avatar

    No random tests

  • Muhamor Avatar

    In test 34060/40 = 851.5 is it should work like this?

  • s-mkokor Avatar

    The Julia Version of the Test seems to have a Problem: Within the Test Results it doesn't show which inputs were used for the test but rather which output. This makes debugging a problem almost impossible becouse you don't now which input caused the problem only which output was supposed to be generated!

  • Lava-Iris Avatar

    Should the result for javascript not be in arrays? I'm getting a result of the same form as the question byt it's showing that as a wrong answer.

    for [ [1, 2], [1, 3], [1, 4] ] I'm getting [ [6, 12], [4, 12], [3, 12]] and it's asking for (6,12)(4,12)(3,12). Which from does it want it in?

  • RodriBerrocal Avatar

    This comment has been hidden.

  • herressy Avatar

    This comment has been hidden.

  • user3988022 Avatar

    I don't really know why, but I have [[77033412951888080, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] for one only test case. I can't really imagine why I can have -5 for one only number from all of pairs from all of test cases. My first idea is that this specific test case have a typo, but it seems like someone passes it successfully and continuously. I know that my current solution is quite dirty but I can't even get it working. So my question is what could be a possible topic to investigate to resolve the issue?

    UPD: Actually tried result formula with different numbers ans found that 77033412951888080 / 14949283383840498, 77033412951888085 / 14949283383840498 and 27115 / 5262 givin one result which is 5.152983656404409. For sure those are not equal numbers, but they are at least till 15 digits after the floating dot. I'm not sure if it's enough to pass the cata and how can I improve my solution to get this +5 to one single number (this is the only fail I face). Not sure what to do in such situation. Is it kata issue, or I have wrong solution?

  • alphaBEE Avatar

    I tried to print the input provided via test cases but it printed an empty string. I cant do operations on empty list. If anyone could help with this it would be great. Thanks.

  • Mohrezakhorasany Avatar

    This was EPIC!!! :)

  • pr0ace1 Avatar

    Can someone clarify the test cases for me please- shouldn't [1,2] -> [2,4,] and [1,3] -> [2,6].?? But this seems too easy. My understanding is that for each input pair of integers, we need to find a pair that produce the same fraction when the first element is put on top of the second in a fraction; and we want to reduce D, the second integer of the output pair- is this correct?

  • J-Kavanagh-Personal Avatar

    Issue with test for the attempt with ruby returning this in the logs #<NoMethodError: undefined method `expect' for main:Object Did you mean? exec>

    unable to complete kata because of this

  • jrwillcox Avatar

    For Python, the instructions indicate the return type should be a list of tuples. convertFracs [(1, 2), (1, 3), (1, 4)] shouldBe [(6, 12), (4, 12), (3, 12)]

    But the tests expect the return type to be a list of lists.

    Also the name of the function is different in the instructions (convertFracs) versus the tests (convert_fracts).

  • emiliodeg Avatar

    This comment has been hidden.

  • yuraab7 Avatar

    Result of test is [[0, 12], [0, 12], [0, 12]] should equal [[6, 12], [4, 12], [3, 12]]. Why?

  • user6940710 Avatar

    One of the tests for Python is incorrect, it fails with a message: [[77033412951888080, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]. All of the denominators are the same in the input array, so the output should be the same, but instead of 77033412951888080 numerator (as in the first item of the input array) the result expects 7033412951888085 in the output array and fails the test, because of the mismatch.

  • dfhwze Avatar

    Perl: are you sure the data types correspond to the ones specified? I've compared the input to Irreducible Sum of Rationals. I get integers there.

    # input: array of array_refs; return: array_ref of integers
    sub convert_fracts {
        my @ls = @_;
        foreach my $xs (@ls) {
            print @$xs[0];     # => ARRAY(0x5572a9bd7e78) -> shouldn't this be an integer?
        }
    
  • ThibaultLemaire Avatar

    Please reword the description to make it clear that D should be the same for all elements.

    Otherwise it doesn't make any sense and I spent way to too long figuring this out.

  • dslakind Avatar

    This comment has been hidden.

  • smenendez19 Avatar

    This comment has been hidden.

  • timezonedesign Avatar

    Can this really happen? I guess I have done it right and passed 10s of tests with my code but here is the error I got. [[77033412951888080, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

    We see three pairs, only first pair is different from my answer. I don't know why is this happening.

  • paulsanchez Avatar

    i find this type of nonsense descriptions way too often...

    lets try and make this better, the kata is not a riddle description... making a problem hard by providing confusing descriptions is not how we practice coding.

    how you go from the imput to the expected value in a concise way.

  • kornet Avatar

    Hello. I completed this kata. But it is marked as unfinished and completed at the same time.

  • dfhwze Avatar

    Powershell:

    What is the expected return type? I'm guessing a String. However, I get weird results.

    Log
     (6,12) (4,12) (3,12)
    
    Should Pass Fixed Tests
    Expected: {(6,12) (4,12) (3,12)}
    But was:  {0 1 2 0 1 2  (6,12) (4,12) (3,12)}
    
  • ejini战神 Avatar
    • Ruby should use snake_case

    • Ruby 3.0 should be enabled (Refer this & this for more detail)

  • FArekkusu Avatar

    This comment has been hidden.

  • FArekkusu Avatar

    This comment has been hidden.

  • FArekkusu Avatar

    New test framework should be used in Python.

  • FArekkusu Avatar

    Some languages (e.g. Python) have tests with empty arrays, while others (e.g. C) don't.

  • dfhwze Avatar

    C: I occasionaly get strange expected values. ( expected=�)

    The expression (as strings) (sact) == (sexpr) is false: actual=`{{765, 1020},{714, 1020},{714, 1020},{680, 1020},{816, 1020},{660, 1020},{680, 1020},{680, 1020},{714, 1020},{510, 1020}}` expected=`�`
    

    Is this a kata issue?

  • Unnamed Avatar

    The result type in the initial solution in C is wrong again, see an old issue below.

  • user9644768 Avatar

    Why the input type in reason is list instead of arrays? Lists are implemented as linked list and do not support O(1) indexed based access, whereas using arrays would be more aligned and consistent with other languages.

  • AndrewDales Avatar

    This comment has been hidden.

  • Untidaled Avatar

    This comment has been hidden.

  • Quaoar Avatar

    [[3, 12], [4, 12], [1, 12]] should equal [[24, 84], [28, 84], [7, 84]]
    I have a problem with the tests that already have the same denominator. How do I determine what the new denominator should be? Also, shouldn't [3, 12] be equal to [21, 84]?

  • Luksonaッ Avatar

    aaaand this is why you have to add random tests ;)

  • KataKatis Avatar

    The concept of the kata is good but translations written at different years and reduction of the fractions are bad. However, the complete tests are bad done (in python). This kata must be improve !

  • spencerjibz Avatar

    Hi mate, whoever translated this kata to Rust, if you can tell me that assertion failed: (left == right) left: [(20174, 34060), (2184, 3406), (25545, 34060)], right: [(20174, 34060), (21840, 34060), (25545, 34060)]

    correct this, my left form is the simpliest at. Clearly if there is 21840/3460, you simplifies further to 2184/3460. Don't let me cheat

  • zLuki Avatar

    Awesome kata! :)

  • LFri Avatar

    This comment has been hidden.

  • Lolshh Avatar

    Why [[69, 130], [87, 1310], [3, 4]] should return [[18078, 34060], [2262, 34060], [25545, 34060]] and not [[3588, 6812], [435, 6812], [5109, 6812]] since Fraction(69,130)+Fraction(87,1310)+Fraction(3,4) --> Fraction(9177, 6812)?

    Can someone give me a hint on this one ?

  • APB9785 Avatar

    Just like the description says, inconsistent tests between languages. It's a whole different problem from one language to the next. My language happens to be one of the PITA ones, so I'll pass on this one. Hope this question can get an update for consistency and a better description as well!

  • Ciprian Amza Avatar

    This comment has been hidden.

  • padnevici Avatar

    Hi guys,

    I need a clarification to find the problem in my alghorithm.

    So as all in this thread I also have issue with latest test

    Actual: [[ 58249154903382, 11303966553627], [89065535922, 11303966553627], [1910571900166, 11303966553627]] Expected: [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

    And this is the only mistmatch I get. Can anyone advice me?

    Thank you, Andrei

  • OmegaAI Avatar

    This kata was a PITA: first coding the solution and then figuring out what edge case was throwing the error at attempt.

    This enjoyer of misery thanks you! :-) Very satisfying to finally figure it out.

  • devinford2 Avatar

    Looking for a little help. I use the greadtest common denominator method from math to find the LCM which seems to work fine until the last case where i get the following reason for failing:

    [[77033412951888080, 14949283383840498], [117787497858827, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

    The values not matching up are the first in each list (77033412951888080 != 77033412951888085). It is such a small difference and I can't seem to see why only this case would fail.

    Thanks in advance for the help!

  • username0 Avatar

    Suggesting that the description would adopt the codewars markdown thingy where you can have different text appear for different languages. It would make the desctiption fit my monitor without scrolling. I ran into this when viewing the problem under the Rust category. Please feel free mark this as solved if it's not worth it to change description over trivial changes like the one suggested here.

  • user4872889 Avatar

    This comment has been hidden.

  • dragonbiketoursvn Avatar

    Question regarding the required syntax for the solution (Javascript). My solution returns the correct numerators and denominators but is rejected due to syntax. Specifically, I wrote the function to return an array of 2-item arrays (each one consisting of the numerator and least common denominator). I see that instead of returning, e.g. [[6, 12], [3, 12], [4, 12]], my function should return (6, 12), (3, 12), (4, 12).

    My question is are the expected parentheses and commas simply string literals? Or is this some data structure with which I'm not yet familiar?

  • mstream Avatar

    Hello everyone,

    I'm stuck with my PureScript implementation. It passes all manual test cases. When it comes to the generated tests though, the inputs comprise of over a hundred fractions. Even after simplifying, their common denominator would overflow the Int type giving an implredictable value. There are data types to handle big numbers but in the end I am constrained to return them back as Ints anyway, which defeats the point of such a convertion.

    Could somebody who accomplished this exercise in Purescript confirm that all the fractions are reductible to numbers within the Int range and my algorithm is just wrong, or perhaps that is a deliberate catch of this exercise and the solution requires a different take?

  • changhe3 Avatar

    Moral of the story: LCM != LCD, you need to simply the fractions first!

  • LionyxML Avatar

    @python Should I know better of what to do with big numbers?

    codewars numpy is a bit old (has no lcm function), also lcm is default from the math library from python 3.9+

    Every lcm I implement seems to fail with large numbers...

    What am I doing wrong? (Code on the next post)

  • OuOLeaf Avatar

    This comment has been hidden.

  • emttiew Avatar

    Hello, I went through all the tests, but I got stuck in one. (27115,5262)(87546,11111111)(43216,255689)

    Expected: equal to (77033412951888085,14949283383840498)(117787497858828,14949283383840498)(2526695441399712,14949283383840498) Actual: (6029237170,1170050802)(9192330,1170050802)(197756416,1170050802)

    I tried using my solution and also c++ std::lcm() to calculate and still got the same lcm = 1170050802 not 14949283383840498 like in the test. Can someone please help me understand this result?

  • Y0uD0ntS4Y Avatar

    I'm getting an error saying that numpy in Python doesn't have a lcm method, which it does.. Is there a fix for this?

  • lonkaan Avatar

    After spending two months in js project, writing small python scripts felt good :d

  • sjoerdvandenbos Avatar

    Hello everyone,

    I believe the Scala version has the actual and expected cases mixed up. Can anyone confirm please?

    Test message:

    Test Failed Expected "([6,12)(4,12)(3,12])", but got "([1,2)(1,3)(1,4])"

  • cuchakma Avatar

    This comment has been hidden.

  • gooyeduck Avatar

    Respected community i do appreciate this platform for helping me to progress my programming logical skill. But unfortunately this kata has spoil my weekend there are no valid solution for this kata. This is very unprofessional to get a kata which is not working properly. Programming enthusiast like me expect better katas which are free of bugs. Honestly speaking this is the worst kata ever, this is kinda nightmare. Please modify the kata so that we can continue our practice.

    Thank YOU

  • ospreyelm Avatar

    Can anyone tell me the input for Ruby test case # 6 (for which expected results have the denominator 2775)? I would like to figure out my mistake without totally giving up ...

  • rkulkarni2304 Avatar

    This comment has been hidden.

  • makusimu_san Avatar

    PHP, test case is incorrect

    [ [69,138], [80,1310] ,[30, 40] ]

    expected result for this test case is

    (262,524)(32,524)(393,524)

    but it's don't i think here was a typo, because input for this result should be

    [ [1, 2] , [8, 131], [3, 4] ]

  • user8436785 Avatar

    Python, at least, doesn't have random tests.

  • javier171188 Avatar

    All complain are about mistaken testcases or problems with the presition, am I the only one who got stuck with Execution Timed Out? u.u

  • alexMoro Avatar

    This comment has been hidden.

  • octomancer Avatar

    Great kata! Really enjoyed it :-) My first working code took 60s to run. My final version took ~0.3s to run. I learned a lot optimising the algorithms :-) The pathological last test case is superb :-) I would not have had to optimise at all if it weren't for that b**tard hehe :-)

    Also, I hand-rolled all my algorithms from memory. I googled nothing except syntax to write my solution :-)

  • nishant-18 Avatar

    This comment has been hidden.

  • NEWESTERS Avatar

    Test case for Swift is incorrect:

    testing([(690, 1300), (87, 1310), (30, 40)], [(18078, 34060), (22620, 34060), (25545, 34060)])
    

    Least common multiplier should be 340600

  • Ilya_sh Avatar

    Hello, it seems to me that tests are calculating incorrectly for:

    lst = [][]int{{69, 130}, {87, 1310}, {30, 40}}

    dotest(lst, "(18078,34060)(2262,34060)(25545,34060)")

    According to your calculations, the common denominator should be - 34060 but this is not true

    In my calculation, the common Denominator should be 68120 You can check it please

  • Haksell Avatar

    Python version should use snake_case.

  • brigaded Avatar

    This comment has been hidden.

  • nmwhitehead Avatar

    How do you make it not time out when the last one has 14949283383840498 as the denomnator? I f...king hate that CodeWars does that. I just want to know if my code works.

  • DeanPol Avatar

    Hey author, get your sh1t together. When in your description you state: "You will have a list of rationals in the form { {numer_1, denom_1} , ... {numer_n, denom_n} }", in no circumstanses should you consider receiving an empty list (1,...,n means you have atleast 1), and yet one of your test cases does just that. Thank you for wasting my time.

  • adichoudhary Avatar

    Nice kata. I must say that Author thinks alot before making the question.

  • sbauer322 Avatar

    Perhaps I'm just doing this wrong, but the Rust 2018 tests for basics_convert_fracts seem to have a typo. For,

    testing(vec![(690, 1300), (87, 1310), (30, 40)], vec![(18078, 34060), (2262, 34060), (25545, 34060)]);
    

    The expected answers are all missing a trailing zero.

  • Dallasss7 Avatar

    I dont understand. I thought the whole point of a common denominator is that the multiplier goes into it whole. Your test cases have numbers that only go in as a fraction. other solutions are using reduce. that is not a common denominator then.

  • jklasd Avatar

    Do you have to optimize the lcm calculation? my code times out but passes the basic test cases

  • user8751232 Avatar

    This comment has been hidden.

  • vad0ss Avatar

    Thank's for you kata!

    But. Why for the test data [[1, 2], [4, 5], [3, 4], [6, 9], [7, 10]] in the tests for the typescript, the answer is (30.60) (48, 60) (45.60) (40.60) (42.60)? 60/9 will not be an integer. My code gives the answer (90,180) (144,180) (135,180) (120,180) (126,180) and passes all other tests, including random.

  • andrewvolodko Avatar

    System.DivideByZeroException : Attempted to divide by zero.

    BUT THERE IS NO FUCKING ZERO!!!!!

    just another one shit kata. I am not able to understand that

  • sdorsher Avatar

    This comment has been hidden.

  • Fadafuq Avatar

    This comment has been hidden.

  • evgeni-nabokov Avatar

    Description:

    where all numbers are positive ints.

    Rust code:

    i64

    Should be:

    u64

  • flyingscorpio Avatar

    In Python one of the tests gives a wrong answer. It says 10/36 should give 24/84 which is not the same. My answer finds 15/54 but the test won't accept it. Could someone check on the tests ?

  • AcemanCW Avatar

    This comment has been hidden.

  • Dubstepic Avatar

    Great Kata! I learnt a lot solving it

  • jaloplo Avatar

    JavaScript test are not properly right I think. It should be changed for Test.assertDeepEquals in order to make a good testing. Please, check in the sample result and the rest of the tests provided. In addition, check the result expected in each of them to be JavaScript compliant.

  • kedomingo Avatar

    This comment has been hidden.

  • jkalasz Avatar

    Nice kata but need more sample testcases.

  • WorldofPeace Avatar

    Hi, I went through all the tests, but I got stuck in one. I noticed that your kata's test case is incorrect because your test data has 8 one (11111111), but to achieve your result must be 7 one . Thank you in advance for your precious help Test Case: [[27115, 5262], [87546, 11111111], [43216, 255689]] Your Result: [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

  • anonconda Avatar

    This comment has been hidden.

  • Unnamed Avatar

    Missing tests with reducible fractions at least in Python. Missing an edge case test with an empty list at least in Python.

  • Unnamed Avatar

    I'm surprised how 40 people actually managed to complete it in C. C fixed (!) test:

    lst: {{69, 138},{80, 1310},{30, 40}} Expected: {{262, 524},{32, 524},{393, 524}}
    Error. Expected {{262, 524},{32, 524},{393, 524}} but got {{180780, 361560},{22080, 361560},{271170, 361560}}
    

    But 80/1310 != 32/524.

  • Unnamed Avatar

    Incorrect type in the initial solution in C. It looks like the expected type is long long (*convertFrac(long long[][2], int))[2]. (And corresponding types in the tests.)

  • jkorinth Avatar

    C++ version: Using a std::vector<int> to represent the rational numbers is awkward and brittle; in theory, I'd have to test whether or not I actually have exactly two numbers in that vector, not 1 or 3 (Monty Python holy grenade problem ;-) ).

    Suggestion: Use std::pair<int, int> as type for the rationals.

  • sachees Avatar

    All the tests pass, but the exit code is 139. What can be the reason? I use c++.

  • hazeltroost Avatar

    One of the java tests is wrong.

    expected:<([18078,34060)(2262,34060)(25545,34060])> but was:<([6026,11353)(754,11353)(8515,11353])>

    All of the first set, above are divisible by 3.

  • dowism Avatar

    In the description it says "where all numbers are positive ints." for the input, then one of the test cases has "[[3.4285714285714284, 12.0], [4.0, 12.0], [1.0, 12.0]] should equal [[24, 84], [28, 84], [7, 84]]". Hmmm... those are not positive ints. Also, the denominators are all the same, so one would assume that "in which D is as small as possible" would be 12, not the 84 that is required if you want the rationals to have ints on the top and bottom. I guess what you meant was that the result must all be positive integers and d is as small as possible, which is an entirely different problem. Can you either be more clear with instructions, perhaps making them accurate, or at least give enough examples that what you meant can be inferred even if your description is inaccurate or unclear?

  • Marceliny Avatar

    again g964 and again bad kata explanation. really, enough!

  • donaldsebleung Avatar

    PureScript Translation Kumited - please accept :D

  • ayzrian Avatar

    in which D is as small as possible and

    N_1/D == numer_1/denom_1

    My code generate (3,6) for pare (1,2) and here D is the smallest, but test code generate (6,12). And such situation in each test. One more example. Expected: '(18078,34060)(2262,34060)(25545,34060)', instead got: '(207,390)(261,3930)(9,12)' But my D is smaller than test D and my answer still correct because 18078/34060 = 207/390 2262/34060 = 261/3930 25545/34060 = 9/12

  • ReagentX Avatar

    None of the solutions pass all tests for Python 3 due to how number precision changed: https://docs.python.org/3/tutorial/floatingpoint.html

    You have to use Python 2.7 to pass this.

  • raccooncho Avatar

    [[77033412951888080, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]] I tried this problem in Python. but i got this message. It said me that '77033412951888080' should be '77033412951888085'. However, because this number is extremly large number and it required to use multiplication, gap '5' between my answer and problem's answer is nonsense. please check this issue quickly.

  • imperativeOO Avatar

    For Python 3.6 the test case with (77033412951888085, 14949283383840498), (117787497858828, 14949283383840498), (2526695441399712, 14949283383840498]) is wrong. The first nominator has to be 77033412951888080 (or there are precision issues with large numbers, but I doubt that).

  • alroiz Avatar

    There is a an error in the GO test cases, the solution to {{69, 130}, {87, 1310}, {30, 40}} should be (36156,68120)(4524,68120)(51090,68120) and not (18078,34060)(2262,34060)(25545,34060). 34060%40 is not Zero.

  • dosim Avatar

    There is an error in the PHP test cases, the solution to (69,131)(80,1310)(30,40) is (180780,361560)(22080,361560)(271170,361560) not (262,524)(32,524)(393,524).

    The same for (6,9)(5,8)(7,8)(2,3)(5,6) is (48,72)(45,72)(63,72)(48,72)(60,72) not (16,24)(15,24)(21,24)(16,24)(20,24).

  • ajaczgz Avatar

    There is an error in the F# test cases, the solution to (690, 1300); (87, 1310); (30, 40) is (180780, 340600); (22620, 340600); (255450, 340600) not (18078, 34060); (2262, 34060); (25545, 34060) as stated in the tests.

  • technomage Avatar

    im returning a string (6,12),(4,12),(3,12) instead of (6,12)(4,12)(3,12) how can i remove the "," ? it must works on all sizes (nnnnnn,ddddd)(nnnnnn,ddddd)(nnnnnn,ddddd)

  • joyze Avatar

    i am trying to do with python, numpy.lcm is not working..

  • yavor Avatar

    This comment has been hidden.

  • xarxziux Avatar

    I'm trying to do this kata in F#. My code passes the sample tests and all the random tests but it gives the following cryptic error message when doing the first part of the automated tests:

    at Microsoft.FSharp.Collections.ListModule.Reduce[T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] reduction, Microsoft.FSharp.Collections.FSharpList`1[T] list) [0x00033] in <58dd0ce1dff9fae1a7450383e10cdd58>:0 
      at FSI_0001.convertFracts (Microsoft.FSharp.Collections.FSharpList`1[T] ls) [0x0001e] in <720d59d74cd84494a7b9368e1d8c4c7c>:0 
      at FSI_0001+Tests.testing (Microsoft.FSharp.Collections.FSharpList`1[T] ls, Microsoft.FSharp.Collections.FSharpList`1[T] exp) [0x00001] in <720d59d74cd84494a7b9368e1d8c4c7c>:0 
      at FSI_0001+Tests+suite@35.Invoke (Microsoft.FSharp.Core.Unit _arg1) [0x0022b] in <720d59d74cd84494a7b9368e1d8c4c7c>:0 
      at Fuchu.Impl+evalTestList@260-1.Invoke (System.Tuple`2[T1,T2] tupledArg) [0x00028] in <56a815db36d21f70a7450383db15a856>:0
    

    I can't tell from this if there is a problem with my code (an edge case I've not considered) or if there's a problem with the tests themselves. Can someone please clarify this?

  • Chrono79 Avatar

    This comment has been hidden.

  • Chrono79 Avatar

    This comment has been hidden.

  • g04-ukyo Avatar

    expected:<([200,20000)(60,20000)(8,20000)(1,2]0000)> but was:<([100,10000)(30,10000)(4,10000)(0,1]0000)> sorry, the 0,1]0000 , I can't understand!!!

  • Thunderbert Avatar

    I'm having problems with one particular test case... I am getting the following error when lst = [ [1, 2], [4, 5], [3, 4], [6, 9], [7, 10] ]; expected '(90,180)(144,180)(135,180)(120,180)(126,180)' to equal '(30,60)(48,60)(45,60)(40,60)(42,60)' Is LCM(2, 5, 4, 9, 10) really 60? My code passes all other tests but this one, it passes even the random tests... I'm not sure if I'm doing something wrong or if there is an issue with the test cases... Also, not sure if it matters or not, but I'm trying to code it in TypeScript.

    EDIT: I found the error, and now I feel dumb for not realizing it sooner...

  • mr-bagglesworth Avatar

    This comment has been hidden.

  • AzureJ Avatar

    Hi, I am using Python(3.4). All other tests pass. May I know why this is happening for the last one? Thanks! [[77033412951888080, 14949283383840498], [117787497858827, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

  • petersowa Avatar

    The random tests appear to be wrong for typescript as the LCD is not always selected:

    ex.:

    expected '(30,60)(48,60)(45,60)(40,60)(42,60)' to equal '(90,180)(144,180)(135,180)(120,180)(126,180)'

    for TEST: 1,2,4,5,3,4,6,9,7,10, RES: 30,60,48,60,45,60,40,60,42,60

  • skex Avatar

    After running several of the solutions to this kata (in Python) I can only assume that the tests have changed since the inception. None of the solutions I tried would clear all of the current tests; some test fails because the true lcm would not have been found, and two tests fails because the assertions of the tests are obviously wrong ([[1480, 2775], [174, 2775], [444, 2775]] should NOT equal [[1480, 2775], [175, 2775], [444, 2775]] for example).

  • skex Avatar

    I'm failing the tests: [[1480, 2775], [174, 2775], [444, 2775]] should equal [[1480, 2775], [175, 2775], [444, 2775]] and [[77033412951888080, 14949283383840498], [117787497858827, 14949283383840498], [2526695441399712, 14949283383840498]] should equal [[77033412951888085, 14949283383840498], [117787497858828, 14949283383840498], [2526695441399712, 14949283383840498]]

    It seems to me that the input should be equal to the output in both of these cases and that the test is wrong. Am I missing something? I'm doing the kata in Python 3.4.

  • 108Shiva Avatar

    I have passed the test cases when I attempt the problem in c++ but it does not display the Sumbit solution button...

  • lkilgoretrout Avatar

    I wrote a solution in python3 that works in my IDE for any test case I can think of and the web-tester says it passes, but the final upload says it fails and gives me a screwy error message:

    [[1, 1], [3, 1], [4, 1]] should equal [[1, 1], [3, 1], [4, 1], [5, 1]]

    How the hell is the solution supposed to have an extra pair of num/denom not even in the input?

  • Late347 Avatar

    This comment has been hidden.

  • Late347 Avatar

    I was doing this in python and apparently I have the wrong parameter type or wrong return type...? I was doing this in PyCharm and I have parameter lst is a list of tuples.

  • Fausthieb Avatar

    This comment has been hidden.

  • Bebeto Avatar

    Tests are wrong!!

    With my code, the result of one test is:

    [[7860, 17030], [2431, 17030], [12876, 17030]] should equal [[322260, 698230], [99671, 698230], [527930, 698230]]

    This is not correct. The gcd is not 698230!! Is 17030, 41 times lower than 698230. So, to be honnest, I would pass the kata if test would be correct.

  • jcislinsky Avatar

    Hi, my solution in Swift produces Process exited prematurely with a SIGILL signal.

    Is there something bad in my solution or another errors occurs?

  • Vinay S R Avatar

    I used the older version of python (2.7) to pass the test. Its failing in the new version as long is not supported

  • Neomien Avatar

    After completed this Kata, I've looked upon the previous solutions and hell... The test cases are not adequate! Almost everybody is using recurse and totally forgets about big numbers!

    Using recursive algorithm with big numbers may be a suicide way (as may kill your stack). A recurse modulo-GCD can go into a 127-deep recurse-chain. (which can cost 24000 CPU-tick vs. iterative version's 490 tick worst case) I highly discourage using that, in particular if there are more ways to avoid the recurse!

    Also if you can't be sure that numbers will always be small enough, then you really should: first divide then multiply! (a * b / gcd() can overflow eg. a = 2^64-2, b > 1)

    Note for strings: repeately building the exact same string from a non-changing "constant" (least common multiplier) in every step in the result-building loop... well you should avoid that too. (always pre-occupy memory (reserve) if you can estimate the usage)

  • adam1984 Avatar

    This comment has been hidden.

  • sudhan Avatar

    Getting timeout error each time i run.

  • NathanWeinstein Avatar

    In C, the casting the long long ** act into a (long long (*)[2] ) is changing the values and I have no idea why.

  • suarezali75 Avatar

    Learned a lot about finding the gcd. Very challenging and pedagogical.

  • odeits Avatar

    rust test cases seem to be wrong

    testing(vec![(690, 1300), (87, 1310), (30, 40)], vec![(18078, 34060), (2262, 34060), (25545, 34060)]);
    

    the lcm of 1300,1310,40 is 340600 this is different than the test case 34060

    see: https://www.wolframalpha.com/input/?i=lcm(1300,1310,40)

  • silentsyk Avatar

    empty array.... what a boring case!

  • gabymorgi Avatar

    I'm working on C# language the test give me this error: "System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

    I copy and paste the expected output in the return sentence => "(6,12)(4,12)(3,12)" and it gave me the same error. When I put a shorter or larger string it say me that the outputs doesn't match. But when I put the exact characters it give me the out of range error. What am I doing wrong?

  • twypsy Avatar

    I think the description should specify what to do in case of dealing with an empty array.

  • colinmcnicholl Avatar

    This comment has been hidden.

  • MikhailViarbitsky Avatar

    In the language of 'С' is not working. Sample test is not working and my code is also not working. Some problem with memory. =/

  • fenchu Avatar

    The final test times out. and I have no clue to why. the initial test is all fine.

  • LFri Avatar

    Could you please post the test case input arrays? The "expected output" does not seem to follow the instructions for all solutions as the second value in the pair cannot always be divided evenly by the first value in the pair. Thanks.

  • albertopha Avatar

    This comment has been hidden.

  • joehuang92 Avatar

    I believe there should be some fallacies in test cases since the description require a minimum D. Other than the case raised by tchar. Also there can be test case like: [[2/4]] which should generate this output: [[1/2]]

    Maybe the author could modify the problem description so that solvers are required to put the l.c.m. as the denominator.

  • yankovai Avatar

    I'm trying to complete this problem using c++ but am getting a SIGSEGV error during attempts. Does anyone have any suggestions for how to resolve this? My guess is that the issue stems from multiplying two large integers when calculating the least common multiple.

  • demon91rf Avatar

    Passed all tests, but can't finish kata. What's problem? I've written code on Java.

  • leigaoyi Avatar

    My solution has a problem about round() when the input number is very large.

  • H1ro Avatar

    Hey. I have trouble allocating memory for result in C language. Error. Expected {{6, 12},{4, 12},{3, 12}} but got {{6, 12},{0, 33},{4, 12}} I have also verified whether by returning shifted array I could reproduce the bug. I did. So at my platform my array is continuos {6,12},{4,12},{3,12}. However, at return, it is read as {6,12},{0,33},{4,12},{0,33},{3,12}. I have verified (to no avail) whether sizeof(long long) is equal on both ends - it is indeed. I am stuck here, and my kata is basically solved (algorithm-wise). Here is how I've allocated said array: http://pastebin.com/yXzTDvGG

  • aamir7117 Avatar

    This comment has been hidden.

  • haugk Avatar

    This comment has been hidden.

  • balintszabo96 Avatar

    This comment has been hidden.

  • mariusz.wisniewski Avatar

    Something is not right when testing my solution. It fails for me on one of the test cases, but when I print my solution, it's the same as expected one:

    XCTAssertTrue failed - should return [(6, 12), (4, 12), (3, 12)] convertFracts 1 : XCTAssertTrue failed - should return [(6, 12), (4, 12), (3, 12)] Log Result: [(6, 12), (4, 12), (3, 12)]

    It it possible == operator fails which makes me fail the test? If I'm not seeing things, my solution is the same as expected one.

  • Sardis93 Avatar

    This comment has been hidden.

  • igal Avatar

    This comment has been hidden.

  • steve-perkins Avatar

    This comment has been hidden.

  • febonachi Avatar

    Hi. Why i have this error? language-Python 3.4.3

    [[12, 84], [28, 84], [7, 84]] should equal [[24, 84], [28, 84], [7, 84]]