Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Yep, definitely.

  • Custom User Avatar

    The third generate function member is a lambda function. [] brackets for variables initialized outside lambda. mutable used here in order to be able modify the k variable.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Use pointers at algorithm library for min/max elements to succeed. It's the only way at this cata & it's owful by the way.

  • Custom User Avatar

    Of Course we will see more "mov' assembler instructions, if we will work with references. Nevertheless the only way to measure optimization of "mov' instructions is time for the CPU to deal with them. As we can see from the benchmarking the CPU managed to sort out 7 additional mov instructions in less time. To summarise, to look only for the amount of generated instructions isn't a precise way to reach a conclusion of optimisation each time.

  • Custom User Avatar

    Hi. I have checked my solution using the chrono library in debug mode.
    Passing by value: 577 microseconds.
    Passing by reference: 386 microseconds.
    Release mode
    Passing by value: 270 microseconds.
    Passing by reference: 271 microseconds.
    Therefore I cant agree with your statement. If you have another idea how to practically measure the difference in another way - please tell me.
    I have spotted an idea of yours in a book, however I try to check everything by myself.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar

    To my mind, the tests for C++ are broken or instruction is not correct. As specified below, 10 isnt a sum of positives elements.
    All other tests have the same problem with positive elements.

    Example
    For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [10, -65].

    In addition, for an " " input the sum elements logically should be 0. This could be harcoded anyway.
    Expected: equal to [ ]
    Actual: [ 0, 0 ]

  • Custom User Avatar

    Hi All.
    What values are used for fixed tests? I don't fully understand why my code passed example_tests & random_tests, but fixed_tests failed.

  • Custom User Avatar

    The composition of two point reflections is a translation. Specifically, point reflection at p followed by point reflection at q is translation by the vector 2(q − p).