Ad
  • Custom User Avatar

    struct AdjacencyLists in the initial code is not used anywhere and its purpose is not explained

  • Custom User Avatar

    the assertion messages are laughable:

    The expression dotest (a, 1) is false.

  • Custom User Avatar

    the code blocks in the description use C with an incorrect language tag (C instead of c) so they do not render properly

  • Custom User Avatar

    The datatypes are all over the place:

    • the return type should be bool
    • pointers to a structure should no be hidden by a typedef; it's super confusing. The input is noted as const Graph *adjacencyLists but what we really are passed is a const struct Edge *const adjacencyLists[], and the typedefs and pointer notation makes this very hard to understand. The latter notation is massively clearer
    • the input graph should be double const: we are supposed to mutate neither the inner structures nor the outer array that contains them
  • Custom User Avatar

    As I had told you, hiding a pointer to a struct under a typedef is really stupid and confusing. You did not address that, which was one of OP's complaint.

  • Custom User Avatar

    This was the third report of it being a duplicate in the comments, so I already sent it back to draft to remove it from the beta pool and avoid it being approved, no retirement necessary.

  • Custom User Avatar

    I noticed you reraised. What do you propose, retire?

  • Custom User Avatar

    Added an example with a picture of a directed graph and an adjacency list description of it.
    Will close issue for now. If any suggestions, make a Suggestion out of it.

  • Custom User Avatar

    When re-reading the Wikipedia article, I noticed it uses "adjacency list" (singular) to describe an array (plural) of linked lists (plural), each linked list describing the "adjacent" vertices of a vertex, whereas I called the type "AdjacencyLists" to reflect the "list/array of lists".

    I'm open to change that if that would help.

  • Custom User Avatar

    AdjacencyLists is basically a wrapper type for Graph *adjacencylists and nvertices, used in the call to isTree.
    It's for additional clarification of the "Node" and "Graph" types, which by itself do not fully describe the data structure.

    It basically models both the (pointer to the) array of Graph with nvertices elements, i.e. all the adjacency lists of all the vertices in the graph, and the number of elements nvertices, in a single type, something that a pointer by itself does not capture.
    You can think of it as the array of (per vertex) adjacency lists. adjacencyLists[i] is the adjacency list of vertex i.

    In the sample code AdjacencyLists is used, and you can also try to understand the data structure from there.

    E.g.

    static int dotest (AdjacencyLists a, int solution) {
      int act=isTree (a.adjacencyLists, a.nvertices);
    

    and in e.g.
    static AdjacencyLists exampleGraph (int code) { ... }

    1. No, because it's a pointer to an array of all adjacency lists, each adjacency list is a Node*/Graph
    2. No, 'prox' is the 'next' pointer of a single adjacency (linked) list
    3. Because it's pointer to an array of Graph

    I you have a suggestion to improve the description, please let me know. The data structure is probably the most difficult part to comprehend; did you read the Wikipedia page on Adjacency Lists?

  • Custom User Avatar

    It is a duplicate of existing polynomial parsing kata. Computing a definite integral of a polynomial function is a simple task (compared to parsing).

  • Custom User Avatar

    I don't see an issue with that, it's unique in its combination, lifting it to a next level.
    There are at least 4 numeric integration Katas, so having multiple katas on the same topic in itself is not an issue.
    And it has a good satisfaction rating by its solvers.
    If you still see a fundamental issue, please re-raise the issue and discuss in here.

  • Custom User Avatar

    also, lol. you like to complain about assertion messages, yet The expression dotest (a, 1) is false. is what you give us ? you need a taste of your own medicine

  • Custom User Avatar

    int is maybe an acceptable bool-ish value in the golfed crap you write for yourself, not in a modern codebase and even less so in a Codewars kata. hiding a pointer to a structure under a typedef is terrible: it makes it look like it's a value type, but it's not, it's passed by reference. you also fail to understand the difference between const type * and type *const, so the input is not actually const in a way that matters.

  • Custom User Avatar

    This Kata still confuses me.

    1. Since Graph is a pointer to a Node, shouldn't isTree() just pass in a Graph and not a pointer to it?
    2. AdjacencyLists isn't used anywhere. Should the prox pointer in Node use this type like the comments suggest?
    3. And, again, since Graph is a pointer, why does AdjacencyLists use a pointer to it?

    Overall I think it may make sense to just remove the type Graph and just use pointer to Node and make it a pointer (that's more clear IMHO).

  • Loading more items...