Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Yep, definitely.
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.
This comment is hidden because it contains spoiler information about the solution
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.
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.
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.
This comment is hidden because it contains spoiler information about the solution
Ok, thanks, my fault.
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 ]
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.
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).