This repo will contain the solutions for https://www.algoexpert.io/ Each solution will reside in its own file with propper summary + tests
- on vs-code go to Code > Preferences > Settings
- look for
format on save - check Editor: Format On Save option
- check Editor: Format On Save Mode option is set to
file
- install tools:
-
pre-commit: https://pre-commit.com/ MacOSX:
brew install pre-commitLinux:pip install pre-commit -
clang-format MacOSX:
brew install clang-formatLinux:sudo apt install clang-format
-
install pre-commit hooks in the repo: on ./githooks folder run:
pre-commit installthis will prevent to commit unformatted code -
execute format script: from root folder run:
./script/format.shthis will format all ur *.cpp and *.h files
-
install Bazel build system: https://bazel.build/install MacOSX:
brew install bazelLinux:sudo apt update && sudo apt install bazel -
commands from root directory:
bazel build //lib:utils
bazel run //exercises/1-two-number-sum:main
bazel run //exercises/2-validate-subsequence:main
bazel run //exercises/3-sorted-squared-array:main
bazel run //exercises/4-tournament-winner:main
bazel run //exercises/5-non-constructible-change:main
bazel run //exercises/6-minimum-waiting-time:main
bazel run //exercises/7-class-photos:main
bazel test --test_output=errors //tests:tests
- install g++ and clang for ur OS check installation versions:
g++ --version
clang --version- install vscode https://code.visualstudio.com/download
- install cpp extension https://code.visualstudio.com/docs/languages/cpp
- build the program open the file in vscode and from it execute: Terminal > Run Build Task
- execute the program go to ./bin directory and run executable file
./exercises/<exercise>/bin/mainie:
./exercises/1-two-number-sum/bin/mainfrom root folder, execute:
g++ -std=c++11 -fdiagnostics-color=always -g ./<exercise>/main.cpp -o ./<exercise>/bin/mainwhere main is the file name of a solution to the we want to build and the name of the executable being created under the exercise /bin/ folder. ie:
g++ -std=c++11 -fdiagnostics-color=always -g ./exercises/1-two-number-sum/main.cpp -o ./exercises/1-two-number-sum/bin/mainfrom root/scripts folder you can
build.sh$excercise- script to build an excercise
- this will create a /bin directory inside the exercise folder
run.sh$excercise- script to run an excercise
- this will execute the ./bin/main.cpp file generated from build process
clean.sh- script to clean all exercises
- this will remove all /bin directories in exercises, only keeping .gitkeep files