Ad
  • Custom User Avatar

    @trashy_incel thank you for that. I have a copy of that site stashed in /home/ and it looks like I didn't visit that page yet. Of course I should consume it more diligently. But it seems to indicate that the specific thing I refer to (and I thought also Mysliwy when saying: "element {func2, func1} (not sure how to name this element, any idea?)") is exactly one part of a compound literal expression, called... an initializer list.

    I guess you would still say I'm being insufficiently precise when I said "making the list into a nameless array" while the nameless array is really only being initialized with it.

  • Default User Avatar

    this is called a compound literal

    an initializer list on the other hand is the {1, 2, 3} in int array[] = {1, 2, 3}

  • Default User Avatar

    Really interesting solution.
    Can someone confirm that I'm understanding it correctly or deny it and explain why?

    • (void(*[])()){func2, func1} - this looks like a casting element {func2, func1} (not sure how to name this element, any idea?) to array of pointers to functions returning type void.
    • [value]() - this is simply calling function which pointer is at index value of the array of pointers to functions, to which we casted {func2, func1}
  • Default User Avatar

    I wanted to ask why it's redundant, because I thought that you are part of the class so your_score affects average score (which is true).
    But when I was writing this comment I realized that although your score affects average it won't affect the overall answer for the question: "Is your_score higher then average in this class?".
    The reason for this is that if including your_score in the average calculations increases average then your score was already higher then average so result won't change. The same happens if your score decreases average.
    Maybe someone will find this explanation usefull so I'm leaving it here.

  • Default User Avatar

    I had to comment on this as it's an incredibly inefficient solution for one simple reason.
    You are calling strlen(walk) twice inside the loop and when you call strlen(walk) you are basically iterating over whole string.
    One small change is required to change time complecity of this algorithm from O(2n^2) to O(2n):

    • Save result of strlen(walk) to variable and replace both occurances of strlen(walk) in your code with this variable.

    Aside from that there is completely no reason to call 'if (strlen(walk) != 10) return false;' inside the loop. Just move it before the loop.