Ad
  • Custom User Avatar

    Question sufficiently answered.

  • Custom User Avatar

    Thanks for this reply.
    I would not have been able to solve this without this hint. The colinear stuff in the description made literally no sense to me.

    It might be cool to add a bit more of a hint (or even the above links to the description) to help the people with shaky math know at least where to look.

    Great challenge.

  • Custom User Avatar

    Lets say we have three points on a plane: A, B and C with coordinates A(xA, yA), B(xB, yB), C(xC, yC). We want to check if these three points are collinear (== lie on the same line). One of the way to do it is to use a formula for the area of a triangle:

                   |xA yA 1|
    S(ABC) = 1/2 * |xB yB 1|
                   |xC yC 1|
    

    The expression after 1/2 is the determinant of a 3x3 matrix.

    So, the points are collinear if and only if this determinant is equal to zero.

    Some links:

    Hope this helps.

    EDIT. Oops, just saw that your question was 2 years ago... :)

  • Custom User Avatar

    Yeah, fixed this

  • Custom User Avatar

    This is a fair point. I will add link to wiki on Isomorphism in set theory sense.

  • Custom User Avatar

    | xA yA 1|
    | xB yB 1| = 0
    | xC yC 1|

    Could someone explain this to me more detail or simpler (some reference maybe)? Sorry, but I dont understand at this part.

  • Custom User Avatar

    Sorry, I think i am not thorough enough to understand the example.

  • Custom User Avatar

    Hi Fairyhunter... In the example, when the clue is 4, always exactly 4 skyscrapers are visible.

  • Custom User Avatar

    May I ask? Are the clues in the description are not always absolute? So, do we have to evaluate each clues? Because in the example, when I see a clue with the value of 4, its just only 2 skyscrappers have been sen.

  • Custom User Avatar

    Maybe you need to test the regex again, because the regex is working fine. And I have to acknowledge it, that this is the cleverest solution I've ever seen. If you test the regex using java find method, the result will be returned very finely (The inner working of Find Method I think). Anyway this is the best solution to reduce the complexity of code.

  • Custom User Avatar

    Nice kata, even though, you still need to visualize your description in the kata before this algebraic isomorphism (isomorphism kata). I had difficulty of understanding the ISO Class, because there is no visualization at all. I think this kata don't need too much logic in it, but It need someone to learn the syntax of their own language. Anyway, this is nice kata, helpful to me for learning the depth syntax of language.

  • Custom User Avatar

    Thanks for your help rosenkranz.

  • 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

    Is it beacuse the picture shows free space, so the array should be 25 and the free space count as " " or ""? The detail shows that just 24 card returned in an array, Am I wrong? Since, I can't debug the test code, because there is no parameter passing, so the test code in server side decides the result and we don't know about the test code in server side.

  • Loading more items...