Ad
  • Custom User Avatar

    Whoops, my bad, I put one of my statement in the wrong order in my code.

  • Custom User Avatar

    Java
    I having problems in the fruit list aryan-firouzian.

    Sample test
    public class SolutionTest {
    @Test
    public void basicTest() {
    assertEquals("apple", Kata.subtractSum(10));
    }
    }

    Fruit list from instructions
    1-kiwi
    2-pear
    3-kiwi
    4-banana
    5-melon
    6-banana
    7-melon
    8-pineapple
    9-apple
    10-pineapple
    11-cucumber
    ...
    Apple is at 9. Yet test is expecting at 10.

    I think your fruit list in instruction is incorrect because I am getting mixed results(1 correct 1 wrong for random numbers) whenever clicking 'Attempt'.

  • Custom User Avatar

    Dectector

    Palindromization - Java 1.8.0_91(Java 8)
    I have problem with the exercise. When I run the sample test without modifying the code I get following error message.
    STDERR:
    /workspace/java/src/KataTests.java:28: error: class, interface, or enum expected
    }
    ^
    1 error

    I noticed that there is addition closing curly brace (}) with no opening brace.

    Default code

    public class Kata {
    public static String palindromization(String elements, int n) {
    return elements;
    }
    }

    Sample Test

    import org.junit.Test;
    import static org.junit.Assert.assertEquals;
    import org.junit.runners.JUnit4;
    public class KataTests {
    @Test
    public void Error_Cases() {

        assertEquals(Kata.palindromization("", 2), "Error!");
        assertEquals(Kata.palindromization("123", 1), "Error!");
    
    }
    
    @Test
    public void Examples() {
        
        assertEquals(Kata.palindromization("123", 2), "11");
        assertEquals(Kata.palindromization("123", 3), "121");
        assertEquals(Kata.palindromization("123", 4), "1221");
        assertEquals(Kata.palindromization("123", 5), "12321");
        assertEquals(Kata.palindromization("123", 6), "123321");
        assertEquals(Kata.palindromization("123", 7), "1231321");
        assertEquals(Kata.palindromization("123", 8), "12311321");
        assertEquals(Kata.palindromization("123", 9), "123121321");
        assertEquals(Kata.palindromization("123", 10), "1231221321");
        
    }
    

    } // No opening curly brace
    }

  • Custom User Avatar

    Thanks for clarifying that. My code is not checking for that, I need to go and fix it.

  • Custom User Avatar

    Thanks for gettin back to me joh_pot. Can I clarify something regard the instructions.
    The function should only return 1 only if the first number contains straight triple and second number contain straight double of the same value digit
    E.g.
    (451999277, 41177722899) == 1 (num1 -triple 999s and num2 -double 99s)
    (451999277L, 411777228L) == 0 (no double 99s in num2)

  • Custom User Avatar

    Hi joh_pot
    The method arguments on test5 were different from yours for me. Originally it was this
    assertEquals(0, TripleDouble(451999277L, 411777228L));

    This was cause compile error because it was not call the static method correctly.

    I have reset challenge and I am still not getting your method arguments. Below are the sample tests provide to me

    import org.junit.Test;
    import static org.junit.Assert.assertEquals;

    public class Tests {

    @Test
    public void test1(){
      assertEquals(1, Kata.TripleDouble(451999277L, 41177722899L));
    }
    
    @Test
    public void test2(){
      assertEquals(0, Kata.TripleDouble(1222345L, 12345L));    
    }
    
    @Test
    public void test3(){
      assertEquals(0, Kata.TripleDouble(12345L, 12345L));
    }
    
    @Test
    public void test4(){
      assertEquals(1, Kata.TripleDouble(666789L, 12345667L));
    }
    
    @Test
    public void test5() {
      assertEquals(0, TripleDouble(451999277L, 411777228L));
    }
    

    }

    This is for java 1.8.0_91(Java 8).

  • Custom User Avatar

    Java
    test5 from sampleTest is incorrect. The static method is being called incorrectly and the expected result is wrong.
    Should be correct to the below
    @Test
    public void test5() {
    assertEquals(1, Kata.TripleDouble(451999277L, 411777228L));
    }
    otherwise test will always fail due compile-time error.
    Joh_pot, you need to fix.