Ad
  • Custom User Avatar

    The problem was you used the 'incorrect' order of operations to complete this kata ;) Should be fine now though.

  • Default User Avatar

    The whites are supposed to be extremely simple.

  • Custom User Avatar

    In my opinion it's too simple to be kata, could for example include some conditional to check whether player is dead/alive, how much health is remaining, how much more damage could take... essentially print some stats :)

  • Custom User Avatar

    No, I tried BigNum but that didn't help. The only one solution that comes to my mind (besides fixing tests) is to write a function that mimic floats rounding of the original platform/ruby version/language.

  • Default User 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));
        }
    }
    

    }

  • Default User Avatar

    I have exactly the same issue.. Did you fix it?

  • Custom User 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"