8 kyu

Grasshopper - Debug

12,729 of 25,410danleavitt0
Description
Loading description...
Debugging
  • Please sign in or sign up to leave a comment.
  • Mehar_unissa Avatar

    what the hoem its same '171.66666666666666 is above freezing temperature' should equal '171.66666666666669 is above freezing temperature' i tried using round but it gave Basic Test Cases '13.333333 is above freezing temperature' should equal '13.333333333333334 is above freezing temperature' Test Passed '0.555556 is above freezing temperature' should equal '0.5555555555555556 is above freezing temperatur

    i couldnt do anything i am using python please fix the issue why would any one want 7 to 8 decimal digits...

  • Kristian-65 Avatar

    can somebody help me debug this question

  • ptd3v Avatar

    My friend will be fired the moment he gets back from the United States. Re-writing would be easier.

  • VDSurChauffe Avatar

    That friend has a serious programming skill issue if he can make a mistake like that on nearly every single line and not understand why everything fails.

  • ttvpro007 Avatar

    Plz fix '0.0 is above freezing temperature' (Python)

  • Sherlock_Walker Avatar

    This comment has been hidden.

  • codejosh Avatar

    This is dog ####. Please fix the Python version.

  • Amirsam_rtz Avatar

    absolutely b.ll sh.t why you need to have 17 chars after . WHY

  • tbali0524 Avatar

    Expected: '0 is above freezing temperature' Actual : '0 is freezing temperature'

    This is a plain wrong. 0 C is freezing and not above freezing. Try it out with water!

  • user3837495 Avatar

    Acheu bem legal o kata, é bom para treina o entendimento e a leitura do codigo.

  • ChadDelany Avatar

    In this practice, it was difficult to determine what the author considered to be a bug and what was not considered to be a bug.

  • arthur2001 Avatar

    In Java Script I found this kata worked for me --> however in Python had issues with:-

    Expected: '13.333333333333334 is above freezing temperature', instead got: '13.333333333333332 is above freezing temperature'..

    I found copying formula from description worked --> I think it is the exact order of operations that causes the problem.

    Hope this helps

  • Don Thruff Avatar

    This comment has been hidden.

  • farhanaditya Avatar

    Too many buuugs

  • user1533868 Avatar

    The whole kata is error. Why this kind of tasks still exists? Some bugs?? Seriously?? It would be more educational to write itt from scratch vs dealing with this "code"

  • -?- Avatar

    Expected: '13.333333333333334 is above freezing temperature', instead got: '13.333333333333332 is above freezing temperature'..

    seriously ??? calculation it self not giving 34 but giving 32 and how the hell I suppose to get that 34 ????

  • acm1812 Avatar

    Had some problems in the beginning, but this was overall an easy kata. Thanks!

  • user4896126 Avatar

    yet another stupid, bad kata take this rubbish down

  • Demotivirus Avatar

    public class GrassHopper {

    public static String weatherInfo(int temp) {
        double c = convertToCelsius(temp);
        if (c > 0)
            return (c + " is above freezing temperature");
        else
            return (c + " is freezing temperature");
    }
    
    public static double convertToCelsius(double temperature) {
        double celsius = (temperature - 32.0) * (5/9.0);
        return celsius;
    }
    

    }

    test5 expected:<23.33333333333333[2] is above freezing t...> but was:<23.33333333333333[6] is above freezing t...>

    1 HOUR I THINK BUT NOT FIND SOLUTION

  • slicecode Avatar

    This comment has been hidden.

  • douwedv Avatar

    Why don't you round the solutions to a significance of 2 or something? These assertions are really bad for a level 8 kata imho. In Java i can't get the whole testsuite to wwork because of some error ini the 9 significance which would be idiotic when it's just a celsius converter.

  • Joel.K Avatar

    Error! expected:<7.77777777777777[8] is above freezing t...> but was:<7.77777777777777[9] is above freezing t...>

  • esanchezr Avatar

    I had the same issue when rounding values in Java:/

  • willy35 Avatar

    expected:<-11.66666666666666[6] is freezing tempera...> but was:<-11.66666666666666[8] is freezing tempera...> LoL

  • seraph76 Avatar

    This comment has been hidden.

  • lukewickens1989 Avatar

    This comment has been hidden.

  • rge123 Avatar

    BEFORE you post another issue about rounding problems in python, java, and js, this kata needs an exact answer. I'd like to draw your attention to the description:

    celsius = (fahrenheit - 32) * (5/9)

    Copy that EXACTLY and you will be fine in python and js. NOTE: division then multiplication. Tests are locked in js, java, and python. If you have rounding problems in other languages then post an issue.

    For java, input temperature as a double not int.

  • niteesh101 Avatar

    this kata is broken guys dont worry

  • swizziedizzie Avatar

    This comment has been hidden.

  • bigcachemoney Avatar

    This comment has been hidden.

  • ia.popovich Avatar

    This comment has been hidden.

  • rememberToDrinkWater Avatar

    Hello everyone, i'm here to say that case tests for Java are broken, since when the program runs the "convertToCelsius" function correctly debugged, it gives back results which are different from the ones in the test cases. Can someone fix it or can i..?

    Thank you for reading, best regards.

  • MadisonAster Avatar

    Test description for python mentions rounding to 1 decimal place, but randomized tests require rounding to a changing number of decimal places.

    '-28.333333333333332 is freezing temperature' should equal '-28.333333333333336 is freezing temperature' '103.88888888888889 is above freezing temperature' should equal '103.8888888888889 is above freezing temperature'

    The tests appear to be generated by a typed library using a double. Rounding in this manner is incompatible with untyped languages. You should change the kata to round to 1 decimal place per your description to provide logical compatability.

  • Dp_dp Avatar

    hey im a bit stuck can anyone help

  • alextaghavi Avatar

    This comment has been hidden.

  • Snake_K-Nut Avatar

    This comment has been hidden.

  • samarb Avatar

    Rounding issue in Python the random tests always fail.

  • KiparD Avatar

    PHP translation is ready! Please check and approve it.

  • KiparD Avatar

    TypeScript translation is ready! Please check and approve it.

  • Subham Kumar Appat Avatar

    This comment has been hidden.

  • vztot Avatar

    For those who stuck on this in java with precision issues u may use BigDecimal with MathContext.DECIMAL128

  • WestwardLand968 Avatar

    Second function's name should be in snake_case in python.

  • WestwardLand968 Avatar

    The second function's name in python should be in snake_case.

  • artpik Avatar

    rounding problem in Python

  • user8042844 Avatar

    rounding problem in Ruby

  • statitica Avatar

    This comment has been hidden.

  • nemus Avatar

    This kata still has a rounding error problem in Java. Since the buggy test data hasn't been fixed after such a long time, perhaps it would be better for this kata to be removed altogether.

  • Chrono79 Avatar

    Why don't you change assertEquals with assertApproxEquals or the equivalent for the other languages? Leaving it like it is a lot of rounding issues will be arised.

  • Konstantin Modin Avatar

    it has some rounding errors: Expected: '-12.222222222222223 is freezing temperature', instead got: '-12.222222222222221 is freezing temperature'

    Expected: '-12.222222222222223 is freezing temperature', instead got: '-12.222222222222221 is freezing temperature'

  • psmilliorn Avatar

    This comment has been hidden.

  • blu.knite Avatar

    This kata is buggy in Java because it depends on implicit formatting of doubles and this can suffer from precision issues. I would recommend one of the following:

    • have the method return just the converted double value and let the unit test acccount for rounding differences
    • include formatting as part of the kata code so that the returned value is deterministic

    This rounding randomness has been pointed out as an issue for years with no change. I recommend dropping this kata.

  • zandraaperjesi Avatar

    The rounding error in java is still not fixed...

  • VitaliiChekalenko Avatar

    This comment has been hidden.

  • carlos.armas Avatar

    Hi, im working with java to solve this kata, but I can't pass the random test because => "expected<number[x] ...> but was<number[y]>", is this normal?, or is this a issue with random test precision expected results? does anyone could help me, I got stuck with this...

  • michal1 Avatar

    Maybe it's necessary to round temperature to 2 digits. Nobody measures temperature with 8-10 digits precision.

  • zimonh Avatar

    There is a rounding error in Java Script

  • spik3scarlett Avatar

    Same issue in ruby :-( there is a rounding error

  • Zu Weichel Avatar

    It looks like there is a rounding error.

  • looni Avatar

    Doesn't work for me. My code in IntelliJ works flawlessly, but when I try to submit the kata I get this error:

    '0.0 is above freezing temperature' should equal '10.0 is above freezing temperature' '0.0 is above freezing temperature' should equal '-5.0 is freezing temperature'

  • tonkhao Avatar

    The same issue here for JS: Expected: '19.444444444444446 is above freezing temperature', instead got: '19.444444444444443 is above freezing temperature' LOL :)

  • MarekWu Avatar

    "expected: < 3.888888888888889[] is above freezing t... > but was: < 3.888888888888889[3] is above freezing t... >"

    cant solve this kata :(

  • arpelayo Avatar

    issue still occurs?

  • skiwichu Avatar

    There's the same issue in Python. My code works fine in IDLE.

    '0 is above freezing temperature' should equal '10.0 is above freezing temperature'

  • user7311016 Avatar

    ruby

    Expected: "-17.77777777777778 is freezing temperature", instead got: "-17.77777777777778 is freezing temperature" Expected: "190.55555555555557 is above freezing temperature", instead got: "190.55555555555557 is above freezing temperature" and another 100 bugs.

    umm... cant solve this kata.

  • tjukes Avatar

    This comment has been hidden.

  • lion999 Avatar

    Java version is impossible to complete:

    expected:<13.33333[3333333334] is above freezing t...> but was:...

  • immovableforce Avatar

    This comment has been hidden.

  • tmxk Avatar

    (using python) Always fail in random tests deal to annoying floating problems before, finally figure out how to pass them..

    To those who sucked in random tests (and who use python?): Once calculate the celsius according to that formula mentioned, round the result to the 12th bit..(I mean something like round(x,12).) At least it works for me.

  • romerojp Avatar

    Submitted Groovy translation, please check it out.

  • Bananiys202024 Avatar

    Kata not work for java. expected:<24.44444444444444[3] is above freezing t...> but was:<24.44444444444444[6] is above freezing t...> Failed. Not work.

  • user3153193 Avatar

    The java variant is impossible to complete with the kata maker having no clue how fractions work in java.

  • Sempertacere Avatar

    Try to change order of operations. Worked for me.

  • grandi22jr Avatar

    Java: Test suite produces invalid "expected" results. Example: expected:<-3.888888888888889[] is freezing tempera...> but was:<-3.888888888888889[3] is freezing tempera...>

    Apparently this is the same issue as has been reported multiple times in the past year and marked resolved, but is not currently functioning correctly.

  • ryancabanas Avatar

    This comment has been hidden.

  • ryancabanas Avatar

    This comment has been hidden.

  • Doug Avatar

    This comment has been hidden.

  • zardoxnet Avatar

    Coding in JavaScript. The test code comparisons are unforgiving, this Kata excercise makes little sense unless there is some level of rounding on the result. My code tests fine on the simple tests but in the extended testing I am getting slight variations due to floating point errors:

    Expected: '29.444444444444446 is above freezing temperature', instead got: '29.444444444444443 is above freezing temperature' ✘ Expected: '-12.222222222222223 is freezing temperature', instead got: '-12.222222222222221 is freezing temperature'

    How can I fix this since I cannot change the test coding

  • user4355430 Avatar

    Yeah, I see the mistake in this line: int c = (int) (temperture - 32 + (5/9.0)); (Java tests)

  • user8239964 Avatar

    Still wrong equation in Java test cases.

  • ChrisTUth Avatar

    The equation is wrong. Java

  • salmariazi Avatar

    Can someone tell me why float(5/9) is not equal to (5.0/9.0) ? I am using python

  • gdmaison Avatar

    I am sort of new here and I a beginner when it comes to java. When I use run test, I pass. But when I click submit, I fail all the test cases. Is any one else facing the same issue? How do i resolve it?

  • olivier_meurice Avatar

    Tests @submit do not work with Java.

  • chandreu Avatar

    on ruby:

    Testing for 75 Test Passed: Value == "23.88888888888889 is above freezing temperature"

    Testing for 39 Expected: "3.8888888888888893 is above freezing temperature", instead got: "3.888888888888889 is above freezing temperature"

    You gotta be kidding me right ???

  • bfirest1 Avatar

    """Testing for 32 '0.0 is freezing temperature' should equal '0.0 is above freezing temperature'"""

    False. Zero is in fact the definition of freezing. To pass tests, I had to return freezing for c < 0, rather than c <= 0, which is the accurate choice.

  • EirikBirkeland Avatar

    for JavaScript: "Expected: 13.333333333333334 is above freezing temperature, instead got: 13.333333333333332 is above freezing temperature"

  • zkopf Avatar

    This comment has been hidden.

  • bvs23bkv33 Avatar

    validation on submit is wrong

  • Dare2Code Avatar

    The test code for Java is utterly wrong!.

  • renzhentaxi Avatar

    Is there anyway to retranslate the java...version

  • lechevalier Avatar

    Not a trace of correct formatted output at all... Why would I need to put a decimal after integers and all decimals after floating numbers?

    Edit: Keep it simple, use str()!

  • rolandas Avatar

    The test code for Java is utterly wrong. celsius = (fahrenheit - 32) * (5/9) not (fahrenheit - 32) + (5/9). Also when temp > 0 it is not freezing temperature.

  • ismaJai Avatar

    It's all wrong, the test cases for submit are wrong. Should be something like this.

    import java.util.Random; import static org.junit.Assert.assertEquals; import org.junit.Test;

    public class PruebasCelsius { String solution(int temperture) { int c = (int) ((temperture - 32) * (5/9.0)); return c + (c <= 0 ? " is freezing temperature" : " is above freezing temperature"); }

    @Test
    public void test1() {
        assertEquals(solution(56), GrassHopper.weatherInfo(56));
    }
    @Test
    public void test2() {
        assertEquals(solution(23), GrassHopper.weatherInfo(23));
    }
    @Test
    public void test3() {
        assertEquals(solution(33), GrassHopper.weatherInfo(33));
    }
    @Test
    public void test4() {
        assertEquals(solution(5), GrassHopper.weatherInfo(5));
    }
    @Test
    public void test5() {
        Random rand = new Random();
        for (int i = 0; i < 50; i++) {
            int num = rand.nextInt(100)+1;
            assertEquals(solution(num), GrassHopper.weatherInfo(num));
        }
    }
    

    }

  • konradx Avatar

    It seems that hardcoded values in tests are generated in different language than ruby(or on diffrerent platform/ruby version) as there is small difference in floating-point calculation. Shouldn't those tests just check for the difference and if it's small enough assume values are equal?

    example:

    Testing for 235 Expected: "112.77777777777779 is above freezing temperature", instead got: "112.77777777777777 is above freezing temperature"

  • jacksonbenete Avatar

    This comment has been hidden.

  • 42piratas Avatar

    This comment has been hidden.

  • kvetals Avatar

    JAVA: absolutely wrong kata... formula at the task is right but all the rest :-( impossible to solve it if you know what it is about)) I decided it only after Test-Cases reading

  • aerotec Avatar

    This comment has been hidden.

  • Insti Avatar

    Ruby: What is the correct expected result for:

    weather_info(32)
    

    There is no explicit test for it but it is occasionally generated by the random tests.

  • sokolas Avatar

    This comment has been hidden.

  • jacobb Avatar

    This is really good debugging practice for beginning programmers.

  • malilav Avatar

    Is one supposed to input a number into the weather function - because i have corrected and reformatted the function to basically works like this: weather_info(convert_to_celsius(number))

    My code does produce the correct answer for all the test cases but i put a number inside the convert function and then pass that as an argument for the weather function. Hence why i get the errror: 10.0 10.0 is above freezing temperature Celsius converter should get correct answer '50 is above freezing temperature' should equal '10.0 is above freezing temperature' Is this acceptable?

  • annunnaky Avatar

    I think it need test case with 0 degrees. It is curious case because it is melting and freezing point at the same time.

  • jesuisuncaillou Avatar

    Not all your tests are requiring the same amount of decimals, so we can't pass them all at once.

    I'm talking about Python.

  • cot032 Avatar

    I talk about Ruby

  • cot032 Avatar

    Your test don't work again Celsius converter should get correct answer Test Passed: Value == "10.0 is above freezing temperature" Test Passed: Value == "-5.0 is freezing temperature" 2 Passed 0 Failed 0 Errors Process took 62ms to complete

    Then I will get Celsius converter should work for fixed tests Expected: "13.333333333333334 is above freezing temperature", instead got: "13.0 is above freezing temperature" Test Passed: Value == "-5.0 is freezing temperature" Expected: "0.5555555555555556 is above freezing temperature", instead got: "0.0 is freezing temperature" Test Passed: Value == "-15.0 is freezing temperature" Expected: "-17.77777777777778 is freezing temperature", instead got: "-18.0 is freezing temperature" 2 Passed 3 Failed 0 Errors Process took 133ms to complete

  • GiacomoSorbi Avatar

    Another sweet one for beginners, translated into both Python and Ruby, but please note that there is currently typo in the test descriptions: celCius instead of celSius.

    Thanks for your work on this one too :)

  • paragonHex Avatar

    This comment has been hidden.

  • eBilk Avatar

    This comment has been hidden.

  • acraileanu Avatar

    Do your random tests work? http://screencast.com/t/Vj66X8aPtQ

  • jpot Avatar

    Correcting simple typos won't teach coding - it would only teach how to correct typos. When you put : instead of = in variable assigment, better make some clear code showing what will those operators do and how they differ. Those aren't common mistakes. I can't imagine someone trying to assign variable with : insted of = nor someone returning cleraly named function argument just next line after assigning another clearly named var.

  • NaMe613 Avatar

    Nice, but it needs a few more bugs.