8 kyu

Find the Slope

3,494 of 10,807elexie
Description
Loading description...
Mathematics
Fundamentals
Algebra
  • Please sign in or sign up to leave a comment.
  • opseg Avatar

    "Assume that [a,b,c,d] and the answer are all integers"

    Yet the unit tests expect strings!

  • Chandan D V Avatar

    There is an issue in test case 1!!

  • alexchelsea22 Avatar

    I dont understand the error in random test, my code is in python, i use two casting requerided and i have this... I dont figure out Testing for: find_slope([19, 61, 45, -3]) It should work for random inputs too: '-2' should equal '-3'

    Testing for: find_slope([-1, 80, 74, 13]) It should work for random inputs too: '0' should equal '-1'

  • Sergenier Avatar

    This comment has been hidden.

  • tonserrobo Avatar

    I could be wrong, but it seems that the random test outputs expect incorrect answers. For example, in cases where y1=y2 the slope should = 0 yet, the test expects -1? :/

  • VDSurChauffe Avatar

    Assume the answer is an integer

    Yet most random tests result in a decimal slope and expect an integer.

  • CommanderCuth Avatar

    This does not seem to be made correctly

  • gary78912 Avatar

    This comment has been hidden.

  • saudiGuy Avatar

    python new test framework + random tests are required. updated in this fork

  • ejini战神 Avatar

    NO random tests in

    • CS
    • Clojure
    • C#
    • Java
    • JS
  • KEVINPRACTICEYUAN Avatar

    This comment has been hidden.

  • Quark Fox Avatar

    is this slop always round number? how? why?

  • bishisht Avatar

    I cannot complete this in ruby even though I have tried in my laptop.

  • ejini战神 Avatar

    C# Function name should use PascalCase

  • laurelis24 Avatar

    Feels wierd that answers has to be strings. Also undefined as string, seems wrong.. Mby im wrong.

  • Argonian Avatar

    This comment has been hidden.

  • farhanaditya Avatar

    It's kinda strange that it expects string as the output, even for non-number values such as undefined

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • AselM Avatar

    (JAVASCRIPT) I cant make it so it will return undefined when it is an impossible slope but i can do the slope part, can anyone help?

  • Angelrina Avatar

    Java sample test cases are still written in wrong syntax.

  • ryancabanas Avatar

    For Java, I discovered that the return String when a denominator value is "0" takes precendence over the return String when the numerator value is also "0".

  • ryancabanas Avatar

    This comment has been hidden.

  • demonation Avatar

    issues with the java example test cases have still not been addressed....

  • user4355430 Avatar

    There are still mistakes in java tests (i can see, they were already reported by spike 11 months ago)

  • kamaln7 Avatar

    (coffeescript): The test cases should be actually undefined and 0, not "undefined" and "0" as strings.

  • fnnntc Avatar

    This comment has been hidden.

  • wawwright Avatar

    Is it just me or does returning the string "undefined" seem like a HORRIBLE idea.

  • IsenrichO Avatar

    I don't know if this is intentional or not, but I feel that the ordering of the input is poor/non-intuitive. If (as the exercise's prompt states) the input is an array [a, b, c, d] representing the two points (a, b) and (c, d), then it stands to reason that a and c are the x-coordinates of the two points; likewise, c and d would be their y-coordinates. However, the slope values expected in the test cases return the reciprocal of the slope. In other words, the expected answers seem to be calculated as the difference quotients of the x-values over the y-values as opposed to the difference quotient of the y-values over the x-values, right?

  • Javatlacati Avatar

    This comment has been hidden.

  • donaldsebleung Avatar

    Needs random tests

  • spike Avatar

    There are three issues with the java version. The test cases need to be written

    // like this
    assertEquals("undefined",s.slope(new int[] {-7,2,-7,4})); 
    
    // not like this 
    assertEquals("undefined",s.slope([-7,2,-7,4]));
    

    Also, the x is switched around with the y. In other words, this means the numerator is switched around with the denominator if you want to make it pass the test, or pass the final submission.

    These three errors with the Java version need to be corrected.

  • rolandas Avatar

    Since a string is returned, it could make sense to add non-integer answer test cases.

  • bencoullie Avatar

    This comment has been hidden.

  • kvetals Avatar

    JAVA: Test cases should be changed this way: from "s.slope([-7,2,-7,4])" to "s.slope(new int[]{-7,2,-7,4})" and so on... Good luck! =)

  • riderj Avatar

    The Java version had some major problems in the test case, the actual value that the test case was testing wasn't proper java syntax.

  • tannert44 Avatar

    Your test should be changed to integers. Right now you are testing to see if integers are equal to a type string. If the person isn't familiar with unit testing, they are going to have it right and think its wrong because the types won't match. Just a suggestion.

  • daedalist Avatar

    Is there a reason that the Python kata expects strings instead of ints for the return value?

  • ryanckulp Avatar

    This comment has been hidden.

  • computerguy103 Avatar

    This comment has been hidden.

  • computerguy103 Avatar

    In Javascript all of the tests expect the result to be a string rather than a number. They should expect the function to return a number.

  • satharsis Avatar

    The Java test cases didn't work for me as well. My solution got accepted though.

  • Daredevil Avatar

    Hi, it's been years since I was coding in JavaScript and I forgot lots of features on the language. I finally passed one of the challenges such as finding the "slope". Can anyone review my code and so I can improve my coding?

    Thanks

  • Abbe Avatar

    I just went through the existing languages. And there seems to be two issues left, even though this kata went live:

    1. The example test cases in Java don't compile. They should be fixed. See comment further down.
    2. Methods in C# normally starts with an uppercase letter. So the method should be called Slope. I don't really think this should be fixed after the kata wen't live, since it will invalidate a bunch of good, working solutions. But just remember it for future katas. :-)
  • matt c Avatar

    This appears to be somewhat of a duplication Here's another kata which has the same issue only difference is the input parameters and expected output.

  • pasbizon Avatar

    This comment has been hidden.

  • pasbizon Avatar

    And also please change test case 2 for Java (you say:"The coordinates should have been [-7,2,-7,4] instead of [7,2,-7,4]").

  • pasbizon Avatar

    I have some problems with test cases. Test cases is written incorrectly. I didn't change anything in tast cases. Problen in Java.

    /SlopeTest.java:13: error: illegal start of expression assertEquals("undefined",s.slope([7,2,-7,4])); ^ /SlopeTest.java:13: error: ')' expected assertEquals("undefined",s.slope([7,2,-7,4])); ^ /SlopeTest.java:13: error: ';' expected assertEquals("undefined",s.slope([7,2,-7,4])); ^ /SlopeTest.java:13: error: not a statement assertEquals("undefined",s.slope([7,2,-7,4])); ^ /SlopeTest.java:13: error: ';' expected assertEquals("undefined",s.slope([7,2,-7,4])); ^ /SlopeTest.java:14: error: illegal start of expression assertEquals("5",s.slope([10,50,30,150])); ^ /SlopeTest.java:14: error: ')' expected assertEquals("5",s.slope([10,50,30,150])); ^ /SlopeTest.java:14: error: ';' expected assertEquals("5",s.slope([10,50,30,150])); ^ /SlopeTest.java:14: error: not a statement assertEquals("5",s.slope([10,50,30,150])); ^ /SlopeTest.java:14: error: ';' expected assertEquals("5",s.slope([10,50,30,150])); ^ /SlopeTest.java:15: error: illegal start of expression assertEquals("-3",s.slope([15,45,12,60])); ^ /SlopeTest.java:15: error: ')' expected assertEquals("-3",s.slope([15,45,12,60])); ^ /SlopeTest.java:15: error: ';' expected assertEquals("-3",s.slope([15,45,12,60])); ^ /SlopeTest.java:15: error: not a statement assertEquals("-3",s.slope([15,45,12,60])); ^ /SlopeTest.java:15: error: ';' expected assertEquals("-3",s.slope([15,45,12,60])); ^ /SlopeTest.java:16: error: illegal start of expression assertEquals("6",s.slope([10,20,20,80])); ^ /SlopeTest.java:16: error: ')' expected assertEquals("6",s.slope([10,20,20,80])); ^ /SlopeTest.java:16: error: ';' expected assertEquals("6",s.slope([10,20,20,80])); ^ /SlopeTest.java:16: error: not a statement assertEquals("6",s.slope([10,20,20,80])); ^ /SlopeTest.java:16: error: ';' expected assertEquals("6",s.slope([10,20,20,80])); ^ /SlopeTest.java:17: error: illegal start of expression assertEquals("undefined",s.slope([-10,6,-10,3])); ^ /SlopeTest.java:17: error: ')' expected assertEquals("undefined",s.slope([-10,6,-10,3])); ^ /SlopeTest.java:17: error: illegal start of expression assertEquals("undefined",s.slope([-10,6,-10,3])); ^ /SlopeTest.java:17: error: ';' expected assertEquals("undefined",s.slope([-10,6,-10,3]));

  • GiacomoSorbi Avatar

    Ruby translation submitted :)

  • MMMAAANNN Avatar

    This comment has been hidden.

  • g964 Avatar

    This comment has been hidden.

  • mahabich Avatar

    The initial code block is not formatted properly - brackets are misaligned.

    The unit tests do not test for edge cases; at a minimum, should test for "undefined".

  • CIS 122 Avatar

    This comment has been hidden.

  • kandelvijaya Avatar

    test should have a double value as expected instead of a int. Because slope is usually presented in double and so "0" != "0.0"