Mindket

The Algorithms Python

Newversion 2 · updated
Star226k

Overview

TheAlgorithms’ open source collection of algorithms and data structures, each written in Python for learning. Setup notes cover reading it on GitHub or its docs site, a clone or ZIP, running a file’s doctests, the dev container, and using Claude Code, Codex or Cursor as a tutor.

The Algorithms Python is an open-source project on GitHub in the Education category, listed by Mindket. It is free. This is version 2, last updated on . Install it from GitHub as its README says. Get Mindket’s setup notes on your Mindket account, as a zip.

At a glance

Runs in
  • GitHub: the README, the folders and each file with its docstring
  • The docs site: https://thealgorithms.github.io/Python/, built with Sphinx from the repository
  • A clone or a ZIP: open the folders in an editor and run a file’s doctests
  • A dev container in Visual Studio Code: the repository ships its own setup
Start with
git clone https://github.com/TheAlgorithms/Python.git
cd Python

Platform

Claude CodeCoding agent
CodexCoding agent
CursorCode editor

About

What it is

The Algorithms Python is a public collection of algorithms and data structures, each one a Python file you can read. The README calls it “All algorithms implemented in Python” and says it is for education. Files sit in folders by topic, such as sorts, searches, graphs, dynamic_programming, ciphers and maths. Contributors write them, and CONTRIBUTING.md asks for type hints, docstrings and doctests, so most files come with examples you can run. The README warns that the implementations “may be less efficient than the implementations in the Python standard library.”

  1. Find a topic in DIRECTORY.md or on the docs site
  2. Open the file and read its docstring
  3. Run its doctests on your own copy
  4. Change the code and run them again

Who it suits

People who learn an algorithm best by reading working code: students, self-taught developers and anyone preparing for interviews. The README says the code is for learning, and GitHub’s topics for the repository include education, interview and practice. It also suits anyone who wants a first open source pull request, since CONTRIBUTING.md welcomes new implementations and better doctests.

Who uses it, and how
WhoHow they use itExample
StudentsRead a file next to a course and run its doctestsA student studying sorting opens sorts/bubble_sort_recursive.py and runs its doctests to see what each call returns.
Self-taught developersWrite their own version first, then compareSomeone writes a greatest common divisor function, then checks it against the cases in maths/greatest_common_divisor.py, such as negative numbers and zero.
Interview candidatesRead the file for a classic problem, then write it again from memoryA candidate reads searches/binary_search.py, closes it and writes the function again.
TeachersSend learners to one folder or file for one topicA teacher gives a class the ciphers folder and asks each student to explain one file.
First-time contributorsFix a doctest or add an algorithm by pull requestA newcomer improves the doctests of one file in a pull request that changes nothing else.

Skip it if you need a library to import in production. The README says the implementations are for learning only and to “Use them at your discretion.”

Where to use it

You can read it anywhere you open a web page, and you can run a file wherever a new enough Python runs (pyproject.toml asks for 3.15 or later).

  • GitHub: the README, the folders and each file with its docstring
  • The docs site: https://thealgorithms.github.io/Python/, built with Sphinx from the repository
  • A clone or a ZIP: open the folders in an editor and run a file’s doctests
  • A dev container in Visual Studio Code: the repository ships its own setup
  • Gitpod: the README carries a Ready-to-Code badge, though Mindket did not open it
  • Chat: a Discord server linked from the README and a Gitter room linked from CONTRIBUTING.md

The repository has an AGENTS.md and three agent skill files, written for people who send or review pull requests and triage issues. Mindket’s notes show how to use Claude Code, Codex or Cursor as a tutor while you read the repository, and they mark which steps are Mindket’s.

How to set it up

Get it saves a zip of Mindket’s setup notes in your downloads folder. The code needs no install to read. To run a file you need Python and your own copy of the repository.

What you need first
NeedDetail
NothingTo read the code on GitHub or the docs site
Python3.15 or later: pyproject.toml says requires-python = ">=3.15", CONTRIBUTING.md asks for free-threaded 3.15t+, and .python-version holds 3.15t. In Mindket’s test run, two files passed on 3.14 and one failed on 3.12 with a SyntaxError
Git or a ZIPA clone, or Code then Download ZIP on GitHub (Mindket’s note: ordinary GitHub, not in the README), gives you the files
PackagesOnly some files import them. pyproject.toml lists numpy, pandas, scikit-learn, httpx2 and others
uvOptional. The maker’s commands use uv and uvx
  1. Read the README on the repository page. It is https://github.com/TheAlgorithms/Python . Or click Code, then Download ZIP, and unzip it (Mindket’s note: ordinary GitHub, not in the README).
  2. Or clone it with the first block below.
  3. Open the folder in an editor and pick a file from DIRECTORY.md.
  4. Run its doctests with the second block, using the file’s path.
git clone https://github.com/TheAlgorithms/Python.git
cd Python

The next command is from CONTRIBUTING.md. Replace my_submission.py with the file’s path, such as sorts/bubble_sort_recursive.py.

python3 -m doctest -v my_submission.py

How to use it

Start from DIRECTORY.md, which lists every Python file under its folder, and open one. Read the docstring first. CONTRIBUTING.md says it should explain the code or link a source such as Wikipedia, and that doctests should cover both valid and erroneous input. So the doctests read as a list of inputs and the answer each must give. Run them. Then change the code and run them again to see what breaks.

Read the end of a file before you run it directly. maths/greatest_common_divisor.py asks you to type two integers, and web_programming/current_stock_price.py requests Yahoo Finance pages.

The grouping below is Mindket’s. The folder names are the repository’s.

Folders by topic
TopicFolders
Data and searchingdata_structures, sorts, searches, hashes, strings
Problem-solving methodsbacktracking, divide_and_conquer, dynamic_programming, greedy_methods, knapsack, graphs, networking_flow
Maths and sciencemaths, matrix, linear_algebra, linear_programming, geometry, physics, quantum, fractals, geodesy, electronics, bit_manipulation, boolean_algebra, conversions
Data and signalsmachine_learning, neural_network, genetic_algorithm, fuzzy_logic, audio_filters, computer_vision, digital_image_processing, data_compression, graphics, cellular_automata
Everything elseciphers, blockchain, file_transfer, scheduling, web_programming, financial, project_euler, other

With an agent, name the file and ask for an explanation or a check, not a rewrite.

Open sorts/bubble_sort_recursive.py and explain in plain words what each doctest checks. Do not change any file.

Example

You open sorts/bubble_sort_recursive.py from the Sorts list in DIRECTORY.md. It opens with “A pure Python implementation of the recursive bubble sort algorithm.” The function takes a type parameter, def bubble_sort_recursive[T: Comparable](arr: list[T]) -> list[T]:, and its docstring holds doctests such as:

>>> bubble_sort_recursive([5, 1, 4, 2, 8])
[1, 2, 4, 5, 8]
>>> bubble_sort_recursive([1, "two"])  # doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: ...

The second example is the file’s rule for bad input: mixing a number and a string must raise a TypeError. You run the doctests with the command above. In Mindket’s test run on 3 November 2026 they passed under Python 3.14 and 3.12, with this file and one other copied from the repository into an empty folder. Then you change the comparison in the function and run them again to see which examples fail.

For newcomers and experts

If you are new. An algorithm is a fixed method for one task, such as putting a list in order or finding an item in it. A data structure is a way to hold data, such as a linked list or a tree. A doctest is an example inside a function’s docstring: a line that starts with >>> is a call, and the line under it is what the call must return. Python’s doctest module runs those examples and reports any that differ. You need to be able to install Python and type a command in a terminal. Start with a folder whose name you know, such as sorts, and open the first file.

For experts. The repository tracks the newest CPython and its free-threaded builds. .python-version holds 3.15t, pyproject.toml requires 3.15 or later, and build.yml runs pytest with pytest-run-parallel and --ignore-gil-enabled. Its comment says some compiled dependencies do not yet ship the slot that keeps the GIL off, so importing them re-enables the GIL under 3.15t.

The build workflow’s pytest run skips four files that import cv2, the digital_image_processing folder, project_euler, docs/conf.py, scripts/validate_solutions.py and two web files. Pre-commit runs ruff, codespell, a filename check, rumdl for Markdown and uv-lock, among others. ty runs as an informational check that does not block a merge yet.

DIRECTORY.md is regenerated by scripts/build_directory_md.py at the end of a passing build. Project Euler answers are checked by scripts/validate_solutions.py, not by doctests, and that folder’s README says the ten slowest solutions show in the Actions logs. The scripts folder also holds shell scripts that close pull requests for missing tests, type hints or descriptive names, which its README ties to the Hacktoberfest rush in October.

Good to know

The code is for study. Read a file before you build on it.

  • License: MIT. LICENSE.md begins “MIT License” and names “TheAlgorithms and contributors” as the copyright holders. project_euler/README.md says its problems come from projecteuler.net and “are licensed under CC BY-NC-SA 4.0”. Check that site before you reuse a problem statement
  • Newer Python: in Mindket’s test run, maths/greatest_common_divisor.py stopped with a SyntaxError on Python 3.12 and passed on 3.14. The cause is an except line with no parentheses
  • Stale setup files: .gitpod.yml and .devcontainer/Dockerfile still mention requirements.txt, which AGENTS.md says the project does not have. On 3 November 2026 GitHub’s raw address for it answered 404. The dev container configuration names an image and not that Dockerfile
  • Skipped in CI: AGENTS.md says some directories are skipped on purpose (the --ignore entries in build.yml), usually because a heavy dependency lacks a wheel. Check that list to see whether a file is tested
  • The web: a few files fetch pages, such as web_programming/current_stock_price.py. The dev container clones two zsh plugins from GitHub
  • Sending a change: one algorithm file per pull request, and at least one box checked in its description, or the algorithms-keeper bot closes it. A vulnerability goes to the maintainers privately, as SECURITY.md says
  • Outbound: reading loads GitHub, the README’s logo from raw.githubusercontent.com and its badges from img.shields.io. git clone and git pull talk to GitHub
  • Removal: delete the folder, and the downloaded ZIP file if you kept it

README and files

README

The Algorithms Python: setup notes

This kit holds setup notes only. Mindket wrote them. The code stays in the TheAlgorithms/Python repository: https://github.com/TheAlgorithms/Python

These notes are not made or endorsed by TheAlgorithms. GitHub's description of the repository is "All Algorithms implemented in Python". The README's own line under its title is "All algorithms implemented in Python - for education", and its first paragraph says "Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion." The notes were written from the README, CONTRIBUTING.md, AGENTS.md, SECURITY.md, LICENSE.md, pyproject.toml, the .python-version file, the dev container files, four of the GitHub Actions workflows (build, ruff, sphinx and ty), the three agent skill files and the docs site's home page, all read on 3 November 2026. A test run of two of the repository's files is described in setup/run-a-file.md.

License: MIT. GitHub's answer for the repository names it "MIT License" (SPDX id MIT), and LICENSE.md begins "MIT License" and "Copyright (c) 2016-2022 TheAlgorithms and contributors". The README of the project_euler/ folder adds that its problems come from https://projecteuler.net/ and "are licensed under CC BY-NC-SA 4.0", so that folder's problem statements have a second license. These notes quote only short lines from the repository, among them two single lines of its code, and name the page each came from. They hold no whole file.

What it is

A public collection of algorithms and data structures, each written in Python as a file you can read, grouped in folders by topic. The README calls the project "All algorithms implemented in Python" and says it is for education. Contributors write the files. CONTRIBUTING.md asks for type hints, docstrings and doctests, so most files carry examples that you can run. Source: https://github.com/TheAlgorithms/Python/blob/master/README.md

The repository's folders, as the table of contents of DIRECTORY.md names them on 3 November 2026: Audio Filters, Backtracking, Bit Manipulation, Blockchain, Boolean Algebra, Cellular Automata, Ciphers, Computer Vision, Conversions, Data Compression, Data Structures, Digital Image Processing, Divide And Conquer, Docs, Dynamic Programming, Electronics, File Transfer, Financial, Fractals, Fuzzy Logic, Genetic Algorithm, Geodesy, Geometry, Graphics, Graphs, Greedy Methods, Hashes, Knapsack, Linear Algebra, Linear Programming, Machine Learning, Maths, Matrix, Networking Flow, Neural Network, Other, Physics, Project Euler, Quantum, Scheduling, Searches, Sorts, Strings, Tests and Web Programming. The list changes as folders are added. Source: https://github.com/TheAlgorithms/Python/blob/master/DIRECTORY.md

Besides the algorithm folders, the repository holds:

  • DIRECTORY.md: a list of every Python file, by folder, that the build regenerates
  • CONTRIBUTING.md, AGENTS.md, SECURITY.md, LICENSE.md and index.md
  • pyproject.toml, uv.lock and .python-version: the Python version and the packages
  • .devcontainer/, .gitpod.yml and .pre-commit-config.yaml: the maker's setup for a dev container, Gitpod and pre-commit
  • .github/: the workflows, the pull request template and three agent skill files under .github/skills/
  • docs/ and scripts/: the Sphinx configuration, and the maker's maintenance scripts

Source: the repository's file tree (https://api.github.com/repos/TheAlgorithms/Python/git/trees/master?recursive=1).

What installs

Nothing from this kit. The repository is source files. To run one, you need Python and, for some folders, third-party packages. See setup/run-a-file.md.

What you need first

  • To read the code: a browser. See setup/read-online.md.
  • To get a copy: Git, or a ZIP download. See setup/get-a-copy.md.
  • To run a file's examples: Python 3.15 or later (pyproject.toml says requires-python = ">=3.15"). Some files fail on 3.12. See setup/run-a-file.md.
  • To use the maker's dev container: Docker and Visual Studio Code. See setup/dev-container-and-gitpod.md.

Per-platform notes

  • setup/read-online.md: GitHub, DIRECTORY.md and the docs site
  • setup/get-a-copy.md: a ZIP, or a clone
  • setup/run-a-file.md: Python version, packages, the maker's test commands and a test run
  • setup/dev-container-and-gitpod.md: the dev container steps in the maker's .devcontainer/README.md, and the Gitpod badge
  • setup/ai-agents.md: the repository's AGENTS.md and agent skill files, and using Claude Code, Codex or Cursor as a tutor (Mindket's steps)
  • setup/contribute-a-change.md: the maker's rules for a pull request

Update or remove

A ZIP is a snapshot: download a new one to get later changes. A clone is updated with git pull (Mindket's note, ordinary Git). To remove either, delete the folder, and the downloaded ZIP file if you kept it.

Outbound connections

  • Reading on GitHub loads GitHub. The README's logo comes from raw.githubusercontent.com and its badges from img.shields.io.
  • The docs site is on GitHub Pages at https://thealgorithms.github.io/Python/.
  • git clone and git pull talk to GitHub.
  • A file you run may reach the web by itself. For example, web_programming/current_stock_price.py requests Yahoo Finance pages.
  • The dev container pulls an image from mcr.microsoft.com and clones two zsh plugins from GitHub. See setup/dev-container-and-gitpod.md.

Sources

Files
README.md  6 KB
setup/ai-agents.md  4 KB
setup/contribute-a-change.md  4 KB
setup/dev-container-and-gitpod.md  4 KB
setup/get-a-copy.md  1 KB
setup/read-online.md  4 KB
setup/run-a-file.md  6 KB

7 files, 28 KB, downloaded as a zip.

What’s new

  • Version 2 · 2026-11-09

    Updated by Mindket to the current version of this kit.

  • Version 1 · 2026-11-03

Compare with similar

Listed GitHub projects in the same category that share the most topics with this one.

ProductStarsActivityLanguageLicenseLast change
The Algorithms Python This page225,927——MIT—
Free Programming BooksShares hacktoberfest · education401,147——CC-BY-4.0—
System Design PrimerShares interview · python377,360QuietPython—
Coding Interview UniversityShares algorithm · interview364,052——CC-BY-SA-4.0—
Hello AlgoShares algorithm · education131,980————
Numbers as Mindket last read them, from 2026-11-07 to 2026-11-09. Activity is read from each project’s last change on GitHub: Active within 30 days, Quiet within 180, Stale after that.

Reviews

No ratings yet

Write a review

No reviews yet.

What people say

Posts and comments that name this project on Hacker News, Bluesky, X, Reddit, Facebook and YouTube, found by a weekly search and on Trendshift. Mindket doesn’t write or check them. Open one to read it where it was posted.

0101111101Algorithms Implemented in Python153 points · 27 repliesAndrii Kuznietsov👨💻🐍The Algorithms / #Python — великий відкритий репозиторій на GitHub, у якому зібрані реалізації алгоритмів і структур даних мовою Python. Проєкт охоплює десятки напрямів, від базового сортування та пошуку до криптографії, машинного навчання й нейронних мереж. github.com/TheAlgorithm...@ZabihullahAtal2. 100 Days of ML Coding → Daily ML practice roadmap → Build consistency while learning Link: https://t.co/BKBao1Nlphr/letscodecommunity10 GitHub repositories to master Python 👇algowizardAlgorithms Implemented in Python6 pointsRepoTendency🔥 "python" is trending on GitHub 1 Jul 2026 — 10 repos (⭐32.0K avg, ⭐222.3K max) 🥇 react/react ⭐246.2K 🍴51.1K forks 📈 TypeScript 16.6% · 👤 TheAlgorithms (9 repos, ⭐374.4K total) 📊 319 repos · 33 keywords · 247 unique authors 🌐 https://github-tendency.vercel.app — full report #GitHub…@_jaydeepkarale3️A curated list with Github stars and forks stats based on awesome awesome-python https://t.co/wJZQDXg3o5r/letscodecommunity10 GitHub repositories every developer should know for DSAtaubekAll Algorithms Implemented in Python5 pointsGitRatedA new AI review! TheAlgorithms/Python ⭐3.9/5.0 TheAlgorithms/Python is a large, actively maintained, community-driven collection of educational algorithm and data-structure implementations. https://gitrated.com/TheAlgorithms/Python@techNmakSomeone quietly built a computer science degree inside a GitHub repository. Sorting. Graphs. Dynamic programming. Data structures. Cryptography. Machine learning. All implemented in Python. Then you see the folders: maths sorts graphs hashes matrix ciphers geodesy physics quantum strings fractals…fzliuAll Algorithms Implemented in Python3 points

Searched

More from Mindket

See all from Mindket

anaksor-ocr

Sokheng · Kit

Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…

New

Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…

New

ACE-Step 1.5 XL SFT

ACE-Step · Kit

Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…

New

Similar projects

See all in Education

Free Programming Books

EbookFoundation · Kit

A community list of free programming books, courses, cheat sheets, interactive tutorials, podcasts and playgrounds in many languages, administered by the Free…

New401k

System Design Primer

donnemartin · Kit

Donne Martin’s organized collection for learning to design large-scale systems and preparing for the system design interview, with worked solutions and Anki de…

New377k

jwasham’s multi-month study plan for becoming a software engineer, written as one long README of videos, lectures and things to implement. Setup notes cover a…

New364k