{"id":15047562,"url":"https://github.com/sir-gon/algorithm-exercises-cpp","last_synced_at":"2025-08-18T14:31:06.527Z","repository":{"id":256111614,"uuid":"854288659","full_name":"sir-gon/algorithm-exercises-cpp","owner":"sir-gon","description":"Algorithms Exercises solved in C++17, running with CMake and Catch2 unittest framework. Developed with TDD.","archived":false,"fork":false,"pushed_at":"2024-10-23T17:00:53.000Z","size":141,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-23T20:59:27.279Z","etag":null,"topics":["algorithm-challenges","algorithms","algorithms-and-data-structures","algorithms-datastructures","catch2","cmake","cpp","cpp17","exercises-code-cpp","exercises-solutions","hackerrank","hackerrank-challenges","hackerrank-cpp","hackerrank-solutions","projecteuler","tdd","test-driven-development","test-driven-development-with-cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sir-gon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sir-gon"],"buy_me_a_coffee":"gonzalodiaz"}},"created_at":"2024-09-08T21:43:12.000Z","updated_at":"2024-10-23T16:46:32.000Z","dependencies_parsed_at":"2024-09-16T19:31:36.516Z","dependency_job_id":"5cec7245-7e1d-4e96-bc3e-2d67e1cbd6c5","html_url":"https://github.com/sir-gon/algorithm-exercises-cpp","commit_stats":{"total_commits":71,"total_committers":4,"mean_commits":17.75,"dds":"0.16901408450704225","last_synced_commit":"07ddfe5ece5ea660cb485a7b85f54f5086f6df7f"},"previous_names":["sir-gon/algorithm-exercises-cpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sir-gon%2Falgorithm-exercises-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sir-gon%2Falgorithm-exercises-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sir-gon%2Falgorithm-exercises-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sir-gon%2Falgorithm-exercises-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sir-gon","download_url":"https://codeload.github.com/sir-gon/algorithm-exercises-cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230240563,"owners_count":18195436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm-challenges","algorithms","algorithms-and-data-structures","algorithms-datastructures","catch2","cmake","cpp","cpp17","exercises-code-cpp","exercises-solutions","hackerrank","hackerrank-challenges","hackerrank-cpp","hackerrank-solutions","projecteuler","tdd","test-driven-development","test-driven-development-with-cpp"],"created_at":"2024-09-24T21:00:18.910Z","updated_at":"2025-08-18T14:31:06.493Z","avatar_url":"https://github.com/sir-gon.png","language":"C++","readme":"# Algorithm Exercises (C++17)\n\n[![C/C++ CMake/GNU Linux CI Test](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-linux.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-linux.yml)\n[![C/C++ CMake/LLVM MacOS CI Test](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-macos.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-macos.yml)\n[![C/C++ CMake/MSVC Windows CI Test](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-windows.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cpp-windows.yml)\n\n[![CppCheck Lint](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cppcheck.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/cppcheck.yml)\n[![Markdown Lint](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/markdown-lint.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/markdown-lint.yml)\n[![YAML lint](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/yamllint.yml/badge.svg)](https://github.com/sir-gon/algorithm-exercises-cpp/actions/workflows/yamllint.yml)\n\n![GitHub](https://img.shields.io/github/license/sir-gon/algorithm-exercises-cpp)\n![GitHub language count](https://img.shields.io/github/languages/count/sir-gon/algorithm-exercises-cpp)\n![GitHub top language](https://img.shields.io/github/languages/top/sir-gon/algorithm-exercises-cpp)\n[![CodeFactor](https://www.codefactor.io/repository/github/sir-gon/algorithm-exercises-cpp/badge)](https://www.codefactor.io/repository/github/sir-gon/algorithm-exercises-cpp)\n[![codecov](https://codecov.io/gh/sir-gon/algorithm-exercises-cpp/branch/main/graph/badge.svg?token=YZ41BE67E4)](https://codecov.io/gh/sir-gon/algorithm-exercises-cpp)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-cpp\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-cpp)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-cpp\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-cpp)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-cpp\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-cpp)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-cpp\u0026metric=code_smells)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-cpp)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=sir-gon_algorithm-exercises-cpp\u0026metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=sir-gon_algorithm-exercises-cpp)\n\n## TL;DR\n\nAlgorithms Exercises solved in [C++17](https://en.cppreference.com/w/cpp/17),\nrunning with [Catch2](https://github.com/catchorg/Catch2) testing suite throug [CMake](https://cmake.org/).\nDeveloped with TDD.\n\n- Package Manager for libraries / dependencies [**vcpkg**](https://vcpkg.io/)\n- JSON reading with [@nlohmann/json](https://github.com/nlohmann/json)\n\n[![C++17](https://img.shields.io/badge/C%2B%2B-00599C?style=for-the-badge\u0026logo=c%2B%2B\u0026logoColor=white)](https://en.cppreference.com/w/cpp/17)\n[![CMake](https://img.shields.io/badge/CMake-%23008FBA.svg?style=for-the-badge\u0026logo=cmake\u0026logoColor=white)](https://cmake.org/)\n[![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge\u0026logo=docker\u0026logoColor=white)](https://www.docker.com/)\n\nGo to [Install and run](#install-and-run)\n\n## What is this?\n\nThis repository is part of a series that share and solve the same [objectives](#objetives),\nwith the difference that each one is based on a different software ecosystem,\ndepending on the chosen programming language:\n\n- [Modern Javascript: algorithm-exercises-js](https://github.com/sir-gon/algorithm-exercises-js)\n- [Typescript: algorithm-exercises-ts](https://github.com/sir-gon/algorithm-exercises-ts)\n\n- [Python 3.x: algorithm-exercises-py](https://github.com/sir-gon/algorithm-exercises-py)\n- [Go / Golang: algorithm-exercises-go](https://github.com/sir-gon/algorithm-exercises-go)\n\n- [Java: algorithm-exercises-java](https://github.com/sir-gon/algorithm-exercises-java)\n- [.NET / C#: algorithm-exercises-csharp](https://github.com/sir-gon/algorithm-exercises-csharp)\n- [C++17: algorithm-exercises-cpp](https://github.com/sir-gon/algorithm-exercises-csharp-cpp)\n\n## Objetives\n\n### Functional\n\n- For academic purposes, it is an backup of some algorithm exercises\n(with their solutions), proposed by various sources:\n[leetcode, hackerrank, projecteuler](#algorithm-excersices-sources), ...\n\n- The solutions must be written on \"vanilla code\", that is,\navoiding as much as possible the use of external libraries (in runtime).\n\n- Adoption of methodology and good practices.\nEach exercise is implemented as a unit test set,\nusing TDD (Test-driven Development) and Clean Code ideas.\n\n### Technical\n\nFoundation of a project that supports:\n\n- Explicit **typing** when the language supports it, even when it is not mandatory.\n- Static Code Analysis (**Lint**) of code, scripts and documentation.\n- Uniform **Code Styling**.\n- **Unit Test** framework.\n- **Coverge** collection. High coverage percentage. Equal or close to 100%.\n- **Pipeline** (Github Actions). Each command must take care of its\nreturn status code.\n- **Docker**-based workflow to replicate behavior in any environment.\n- Other tools to support the reinforcement of software development **good practices**.\n\n## Install and Run\n\n- (⭐️) [Install and run directly with make](#install-and-run-directly-with-make)\nrequire runtime tools and GNU make installed in your SO.\n\n\u003e [!NOTE]\n\u003e Please see [Environment Notes](docs/Environment-Notes.md) for more details\n\u003e about the tools required for your environment. In particular, **Windows**.\n\n- [Install and in Docker](#install-and-running-with-docker-) require Docker and\ndocker compose installed.\n- [Install and in Docker with make](#install-and-running-with-docker--using-make)\nrequire Docker, docker compose and GNU make installed.\n\n⭐️: Prefered way.\n\n### Install and run directly with make\n\nIt is assumed that the following tools have already been installed:\n\n- [**GNU make**](https://www.gnu.org/software/make/)\n- [**CMake**](https://cmake.org/)\n- [**vcpkg**](https://vcpkg.io/)\n- [**CppCheck**](https://cppcheck.sourceforge.io/)\n- [**(LLVM) clang-format**](https://clang.llvm.org/docs/ClangFormat.html)\n\nUsing a  runtime in your SO. You must install dependencies:\n\n```bash\nmake dependencies\nmake lint # optional\nmake build\nmake test\n```\n\n#### Test run with alternative behaviors\n\nNot implemented yet\n\n#### Examples running tests with alternative behaviors\n\n### Install and Running with Docker 🐳\n\nBuild an image of the test stage.\nThen creates and ephemeral container an run tests.\n\n```bash\ndocker compose build algorithm-exercises-cpp\ndocker compose build algorithm-exercises-cpp-lint\ndocker compose build algorithm-exercises-cpp-test\ndocker compose build algorithm-exercises-cpp-dev\n```\n\n```bash\ndocker compose --profile testing run --rm algorithm-exercises-cpp-test\n```\n\n### Install and Running with Docker 🐳 using make\n\n```bash\nmake compose/build\nmake compose/lint # optional\nmake compose/test\n```\n\n## About development\n\n```sh\ncmake --version\n```\n\n```text\ncmake version 3.30.3\n\nCMake suite maintained and supported by Kitware (kitware.com/cmake).\n```\n\n---\n\n```sh\nvcpkg --version\n```\n\n```text\nvcpkg package management program version 2024-08-01-2024.08.01\n\nSee LICENSE.txt for license information.\n```\n\n---\n\n```sh\ng++ --version\n```\n\n```text\nApple clang version 15.0.0 (clang-1500.3.9.4)\nTarget: x86_64-apple-darwin23.6.0\nThread model: posix\nInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n```\n\n---\n\n```sh\ncppcheck --version\n```\n\n```text\nCppcheck 2.15.0\n```\n\n## Algorithm excersices sources\n\n- [Leetcode](https://leetcode.com/) online platform for\ncoding interview preparation.\n- [HackerRank](https://www.hackerrank.com/) competitive programming challenges\nfor both consumers and businesses.\n- [Project Euler](https://projecteuler.net/) a series of computational problems\nintended to be solved with computer programs.\n\nUse these answers to learn some tip and tricks for algorithms tests.\n\n### Disclaimer. Why I publish solutions?\n\nAs Project Euler says:\n\n\u003chttps://projecteuler.net/about#publish\u003e\n\n```text\nI learned so much solving problem XXX, so is it okay to publish my solution elsewhere?\nIt appears that you have answered your own question. There is  thing quite like that \"Aha!\" moment when you finally beat a problem which you have been working on for some time. It is often through the best of intentions in wishing to share our insights so that others can enjoy that moment too. Sadly, that will rarely be the case for your readers. Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself.\n\nHowever, the rule about sharing solutions outside of Project Euler does not apply to the first one-hundred problems, as long as any discussion clearly aims to instruct methods, not just provide answers, and does not directly threaten to undermine the enjoyment of solving later problems. Problems 1 to 100 provide a wealth of helpful introductory teaching material and if you are able to respect our requirements, then we give permission for those problems and their solutions to be discussed elsewhere.\n```\n\nIf you have better answers or optimal solutions, fork and PR-me\n\nEnjoy 😁 !\n\n## Status\n\n### License\n\n[LICENSE.md](LICENSE.md)\n\n### Coverage\n\n[![Coverage](https://codecov.io/gh/sir-gon/algorithm-exercises-cpp/graphs/tree.svg?token=YZ41BE67E4)](https://codecov.io/gh/sir-gon/algorithm-exercises-cpp)\n","funding_links":["https://github.com/sponsors/sir-gon","https://buymeacoffee.com/gonzalodiaz"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsir-gon%2Falgorithm-exercises-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsir-gon%2Falgorithm-exercises-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsir-gon%2Falgorithm-exercises-cpp/lists"}