Here are my solutions to the codility lessons. You can find the lessons here.
Details Legend: D = Difficulty; TS = Task Score; C = Completeness; P = Performance; TC = Time Complexity
Assuming you are using cmake, tests will be located in your $BUILD_DIR}/bin
directory. All tests are in the same codility
binary. Individual tests can be run per the googletest framework documentation. Here is a quick reference:
/path/to/build/bin> codility --help
/path/to/build/bin> codility --gtest_list_tests
/path/to/build/bin> codility --gtest_filter=TestName.Test
/path/to/build/bin> codility --seed 12345
Test are built using the following packages. Use CMake and the dependencies will be downloaded and built for you.
You can build the tests for your favorite development environment using cmake
. e.g.:
- For the command line:
mkdir test/build
cd test/build
cmake ..
make
- For XCode:
mkdir test/xcode
cd test/xcode
cmake -G Xcode ..
make
Tests will be created in the bin
directory located wherever you ran cmake from (test\build\bin
in the example above).
You are welcome to contribute provided you accept the Contributor Covenant Code of Conduct. Also, please do the following:
- Submit a pull request. In the PR, Tell me how you figured out what you figured out. Links and background are very much appreciated (e.g. I used the binomial distribution found here. This is commonly used to solve this class of problem because my professor told me...). Remember, part of this code base is to educate.
- Sign your commits.
- Comment your code!
- Look at the other source files and follow the same general style and naming conventions. Most importantly, use meaningful variable names, e.g.
- bad example: int a, aa, a1, a1a, aaaaa;
- good example: int a, b, average, numDogs, temperature;
- Learn and use my test methodology. For function.cpp, I create functionTest.cpp with a solution() and bruteForce() method. Please use this when it makes sense. Simple solutions probably don't need it. If you are optimizing one of my methods that I couldn't figure out, please use the test methodology.
This repository is licensed under The Unlicense.
- Thank you to the gflags command line parsing library.
- Thank you to the googletest C++ test framework.
- Thank you to @arthurafarias for providing the optimized solution to MinAvgTwoSlice