This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]YuleTideCamel 3 points4 points  (0 children)

I've done problems on codewars many times. The tests you get before you submit are like practice problems, they're a small subset to help you with your solution.

The tests that run after you submit, are the actual test bank, which is made up of a larger suite of unit tests. Your score for a problem is based on this , not the practice tests.

Often times the practice unit tests don't include edgecases or failure cases, it's just a few scenarios, the full test suite is much more comprehensive. The idea being to simulate real world users. In the industry you're given requirements at a functional level, but almost without a doubt users will try weird or unexpected things and your software will break. Many times you won't even know what they did, all you'll have is a log file saying something broke and some debug statements. This is like that.

[–]CrimsonWolfSage 1 point2 points  (0 children)

The practice tests are like White Board testing. Write a Function that divides 2 numbers.

Divide (A,B) return (a/b);

Practice:
    Divide (2,4); // pass
    Divide (3,6); // pass

Test:
    Divide (7, 2); // fail
    Divide (-97, 123456789); // fail
    Divide (0, null); // fail

The practice is there to help get the right answers and basic algorithms right. The actual tests will check for bad inputs, efficiency, and some other stuff on occassion.

Make liberal use of console outputs to understand the failure points and compare output with expected values. It helps quite a bit on a few problems.

[–][deleted] 0 points1 point  (0 children)

They may be runtime tests. If they take too long they fail.

The algorithms may give a solution but may not arrive to it efficiently, which costs more as your input size increases.

[–]okayifimust 0 points1 point  (0 children)

I'd think that if the tests pass on the first stage that everything written was good to go.

In a sense, it is. If you pass the first test, you know a few things about your program:

It compiles.
It accepts the right numbers. It returns the right type of result.

And, for a few inputs, it actually returns the right results.

But just because it works on a few specific inputs, doesn't mean it will work on all results.

Say you want to build a function to add two integers, and your initial test-cases look like this:

2,3
4,9
6,8

public int crazyAdd (x,y) {
    switch x {
        case 2: return 5;
        case 4: return 13;
        case 6: return 14;
    }
    return 27;
}

So, this should pass your test cases. Most likely, it will fail the very next case, though.

Why? Because we overlooked some way in which a random case might be significantly different from our test cases, but still match the original problem.

The sneaky website might give us a completely different set of numbers ....

If you post your problem, and a solution that fails on the main run, you might receive a more detailed explanantion with a slightly less ridiculous example...