Ad
  • Custom User Avatar
  • Custom User Avatar

    Hmm, seems this kata is in limbo. Description has multiple spelling issues. I find the names of the data structure misleading, even a Wikipedia link does not help that much. The argument to the function is a basically an array, so please use C arrays, that helps to understand what's happening.

  • Custom User Avatar

    At this point this kata is basically a duplicate of a mixture of katas:

  • Custom User Avatar

    @hobovsky the author doesn't seem to active.

    • Why not? It seems you're thinking about the graphs in the sense of discrete mathematics or networks, the author perhaps meant graphs in the sense of plots of polynomial functions.

    • Should I remove this, or add it as dropdown?

    • Wait, aren't the coefficient already have possiblility to be negative and fractional? and apart from that it is better to say that coefficients are real numbers.

    • I guess it is better just to say compute the definite integral of the given polynomial function in the given interval.

    • .

    • I've prepared them(but not added them yet)

    • Okay, I'll change them to doubles.

    And What rank would you suggest to this?

  • Default User Avatar

    It's not clear if the possible root to check is always the first vertex or it can be any.

  • Custom User Avatar

    You can check my C# translation for proposed improvements, or let me know what changes you made so I could adapt the C# translation where necessary.

  • Custom User Avatar

    You are right! I will alter it as soon as i can .. aswell as provide arbitrary exponent range in (natural numbers however).

  • Custom User Avatar

    I provided a C# translation - please review and let me know if it's ok, or something should be adjusted (range of coefficients or exponents for random tests, comparison tolerance, or anything else).

  • Custom User Avatar

    Damn, it's been AGES since I've written any C code!
    I liked this kata, but I see following issues:

    • GRAPHS as a tag?
    • I find all this matrix stuff a bit... misleading? Or maybe rather distracting, as I was not even aware of such property and solved the problem using another property (namely the fact that Int(ax^n) = a/(n+1)x^(n+1)).
    • I would change "Don't forget coeficients can be negative." to "Don't forget coefficients can be negative or fractional.". I know it's very logical that in general coefficient can be any real number, but examples slightly suggest they may be just integers in this kata.
    • I don't like the fact that definite integral is equated to the "area under the curve", because without further explanation it is ambiguous: how should the area be treated in ranges where f(x) < 0? Is area also 'negative', and should be substracted? Or maybe we treat area as always positive and should be added to the result? Not being a mathematician I do not know what the formal definitions is, but for the kata I see this ambiguity as an issue.
    • Isn't using roundf a bit of a stretch? This way, both of these pass: dotest('y', 0, 1, " y^7 + 2y^4 + 1 -y^7 ", 1.4); and dotest('y', 0, 1, " y^7 + 2y^4 + 1 -y^7 ", 0.6);. My implementation can return anything between 0.5 and 1.5 and test will still pass. Isn't epsilon-based comparison better?
    • No random tests :( Maybe I will create some when translating to Java or C# ;)
    • Why floats and not doubles? With high exponents or large coefficients, precision loss may be significant enough to make valid solutions not pass the tests.
  • Custom User Avatar

    Your are right. I tried to illustrate the topology not the flow.

    To clarify the root is the only node that can reach every other.

  • Default User Avatar

    There are pictures of both directed and undirected graphs in the description, what is expected is not really clear. As I can see, the list of edges is not symmetrical, so it looks like the graphs are directed. So should it be checked that all the edges point either from or to the root?

  • Custom User Avatar

    That's great advice! It has been added to the discription.

  • Custom User Avatar

    Nice kata!

    It took me longer than I am comfortable to admit to find out that struct edge is a linked list where dest is the index of a node in the graph.
    For convenience you could add a function to the description that shows how a graph is accessed and printed.

    void print_edges(Graph *g, int NV) {
        for (int i = 0; i < NV; ++i)
            for (struct edge *e = g[i]; e; e = e->prox)
                printf("%d - %d\n", i, e->dest);
    }
    
  • Custom User Avatar
  • Custom User Avatar

    Random tests are implemented.

  • Loading more items...