Ad
  • Custom User Avatar

    The test cases did work just fine when I ran them on my computer too, but that says nothing about what's happening on the server side.

    1. Codewars is running your code against a suite of test cases that differ from the ones coming with the kata.
      This is to make sure you won't simply write a program that will only satisfy the unit test of the kata instead of a generic solution to the puzzle.

    2. Their server won't simply open a bash shell and run your code in a JVM instance on it.
      If they did, they would risk having their computers hacked. Any JVM 0day exploit that lets you manipulate the machines physical memory and it's "game over" for them.

    Because of that, they probably run any submitted code in some kind of disposable, sealed of environment. That environment, whatever it actually is, only mimics the behaviour of a JVM.
    You should not expect for your code to run in their environment in the same manner it does on yours. I am supremely sure they disabled many features in that "fake JVM" for security reasons.
    It may help thinking of it as a particularly nit-picky JVM that will give up the very moment it spots something fishy going down.

    As in my case, I suspect the "fake JVM" didn't take kindly to my attempt at a deep copy of the result set and botched big time. I can't say if my "fix" will work for you, but you may want to
    make sure you are using a String array that has been properly initialised to return your result set too.

  • Custom User Avatar

    The free tile is indeed a bit of a bummer as the kana doesn't say exactly what to make of it, but I don't think that's the issue here.
    The standard test cases will fail if you have an empty element in the N column, regardless if null, empty or a single whitespace.

    UPDATE:
    Just got my solution accepted. Originally I would collect my elements in a Vector and summarly return them like so:
    Vector rv = new Vector();
    ... composing card fields here
    String[] rs = new String[ 24];
    return rv.toArray( rs);

    SOLUTION: I simply drew up a String[24] and put them all into that instead of a vector. That did the trick.

  • Custom User Avatar

    Since I am new to the site, I can only offer wild guesses, but I'd wage a penny or two on an overzealous unit test that was trying to be too smart for its own good. In other words: "I guess OP should have unit tested his/her own unit test" ^^

  • Custom User Avatar

    NullPointer Exception on submitting answer

    I'm getting a bogus NullPointer Exception on submitting my solution. Run Tests is working nicely.
    For the life of me, I don't see where that could have been my bad. Stack trace below doesn't look as if I had a hand in it.
    After all, I only return 24 Strings in an array ... what could possibly go wrong?

    java.lang.NullPointerException at java.util.regex.Matcher.getTextLength(Matcher.java:1283) at java.util.regex.Matcher.reset(Matcher.java:309) at java.util.regex.Matcher.(Matcher.java:229) at java.util.regex.Pattern.matcher(Pattern.java:1093) at clojure.core$re_matcher.invokeStatic(core.clj:4674) at clojure.core$re_find.invokeStatic(core.clj:4716) at clojure.core$re_find.invoke(core.clj:4716) at codewars.runners.java$class_name.invokeStatic(java.clj:14) at codewars.runners.java$class_name.invoke(java.clj:11) at codewars.runners.java$source_code_file.invokeStatic(java.clj:35) at codewars.runners.java$source_code_file.invoke(java.clj:30) at clojure.core$map$fn__4785.invoke(core.clj:2646) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.RT.seq(RT.java:521) at clojure.lang.SeqIterator.hasNext(SeqIterator.java:38) at com.sun.tools.javac.api.ClientCodeWrapper.wrapJavaFileObjects(ClientCodeWrapper.java:140) at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:132) at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:107) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93) at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) at codewars.runners.java$compile_and_load.invokeStatic(java.clj:83) at codewars.runners.java$compile_and_load.doInvoke(java.clj:79) at clojure.lang.RestFn.invoke(RestFn.java:439) at codewars.runners.java$fn__599.invokeStatic(java.clj:110) at codewars.runners.java$fn__599.invoke(java.clj:105) at clojure.lang.MultiFn.invoke(MultiFn.java:229) at codewars.runners$run.invokeStatic(runners.clj:22) at codewars.runners$run.invoke(runners.clj:17) at codewars.core$_main$fn__664.invoke(core.clj:40) at clojure.lang.AFn.call(AFn.java:18) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:745)