Ad
  • Default User Avatar
  • Default User Avatar

    Can someone explain me this code ?

  • Custom User Avatar

    The issue is, when I throw an exception from the intProgress method, the tests don't have the exception in their signatures, so the exception is treated like an uncaught exception.

  • Default User Avatar

    java.lang.AssertionError: Expected exception: java.lang.Exception

    Its saying that during an assertion, the tests expected an exception from your code but did not recieve one.

    In the prompt it tells you that any rank that isn't -8 through -1 or 1 through 8 should throw an exception

  • Default User Avatar

    can someone explain me the following error message? don^t understand it.

    xpected exception: java.lang.Exception
    Stack Trace

    java.lang.AssertionError: Expected exception: java.lang.Exception
    at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:34)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
    at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
    at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.codewars.junit5.TestRunner.executeTests(TestRunner.java:64)
    at com.codewars.junit5.TestRunner.lambda$execute$0(TestRunner.java:56)
    at com.codewars.junit5.TestRunner.callWithCustomClassLoader(TestRunner.java:147)
    at com.codewars.junit5.TestRunner.execute(TestRunner.java:56)
    at com.codewars.junit5.TestRunner.main(TestRunner.java:44)

  • Default User Avatar

    For anyone who might be confused, as I originally was, in why some tests fail in Attempt, please know that not only are individual test cases put forward, but at some point the tests start becoming CUMULATIVE. So do not assume all test attempts start with your user at -8 rank and 0 progress... the tests will, for example, apply an activity progress of +1, then then +1 again, then +1 again, etc.

    I wish this had been made clearer in the description as it was a nightmare to debug - I had to purposefully fail ALL tests so that I could see every test being applied and follow along in my code to see when the progressive tests started.

  • Default User Avatar

    what is the advantage of using a Set ? and not something from the List interface.

  • Default User Avatar

    No, only one combination.

  • Default User Avatar

    Can the List you should return contain more than two indexes? if more than 1 combination equals the target number.

  • Default User Avatar

    i did it in the same way, but i passed all the test

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    No, you don't, [2, 4, 1, 5] isn't sorted and the max value is at the end.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Your code only checks if the maximum value is at the first or last place in the array, which doesn't actually answer the question of wether the array is sorted or not.

  • Default User Avatar

    import java.util.*;
    class Solution {

    public static String isSortedAndHow(int[] array) {
    int max = array[0];
    for(int i = 0; i < array.length; i++) {
    if(max < array[i]) {
    max = array[i];
    }

    }
    
     
    if(max == array[array.length - 1]) {
      return "yes, ascending";
    

    }

    if( max == array[0]) {
      return "yes, descending"; 
    }
    return "no"; 
    

    }

    }
    it wont pass Test3 should return no but was yes, ascending
    can someone help out??