|
1 | | -<div align="center"> |
2 | | -<!-- Title: --> |
3 | | - <a href="https://github.com/TheAlgorithms/"> |
4 | | - <img src="https://raw.githubusercontent.com/TheAlgorithms/website/1cd824df116b27029f17c2d1b42d81731f28a920/public/logo.svg" height="100"> |
5 | | - </a> |
6 | | - <h1><a href="https://github.com/TheAlgorithms/">The Algorithms</a> - Python</h1> |
7 | | - |
8 | | -<!-- Labels: --> |
9 | | - <!-- First row: --> |
10 | | - <a href="https://gitpod.io/#https://github.com/TheAlgorithms/Python"> |
11 | | - <img src="https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square" height="20" alt="Gitpod Ready-to-Code"> |
12 | | - </a> |
13 | | - <a href="https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md"> |
14 | | - <img src="https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3&style=flat-square" height="20" alt="Contributions Welcome"> |
15 | | - </a> |
16 | | - <img src="https://img.shields.io/github/repo-size/TheAlgorithms/Python.svg?label=Repo%20size&style=flat-square" height="20"> |
17 | | - <a href="https://the-algorithms.com/discord"> |
18 | | - <img src="https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=7289DA&style=flat-square" height="20" alt="Discord chat"> |
19 | | - </a> |
20 | | - <a href="https://gitter.im/TheAlgorithms/community"> |
21 | | - <img src="https://img.shields.io/badge/Chat-Gitter-ff69b4.svg?label=Chat&logo=gitter&style=flat-square" height="20" alt="Gitter chat"> |
22 | | - </a> |
23 | | - |
24 | | - <!-- Second row: --> |
25 | | - <br> |
26 | | - <a href="https://github.com/TheAlgorithms/Python/actions"> |
27 | | - <img src="https://img.shields.io/github/actions/workflow/status/TheAlgorithms/Python/build.yml?branch=master&label=CI&logo=github&style=flat-square" height="20" alt="GitHub Workflow Status"> |
28 | | - </a> |
29 | | - <a href="https://github.com/pre-commit/pre-commit"> |
30 | | - <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" height="20" alt="pre-commit"> |
31 | | - </a> |
32 | | - <a href="https://docs.astral.sh/ruff/formatter/"> |
33 | | - <img src="https://img.shields.io/static/v1?label=code%20style&message=ruff&color=black&style=flat-square" height="20" alt="code style: black"> |
34 | | - </a> |
35 | | - |
36 | | -<!-- Short description: --> |
37 | | - <h3>All algorithms implemented in Python - for education 📚</h3> |
38 | | -</div> |
39 | | - |
40 | | -Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion. |
41 | | - |
42 | | -## 🚀 Getting Started |
43 | | - |
44 | | -📋 Read through our [Contribution Guidelines](CONTRIBUTING.md) before you contribute. |
45 | | - |
46 | | -## 🌐 Community Channels |
47 | | - |
48 | | -We are on [Discord](https://the-algorithms.com/discord) and [Gitter](https://gitter.im/TheAlgorithms/community)! Community channels are a great way for you to ask questions and get help. Please join us! |
49 | | - |
50 | | -## 📜 List of Algorithms |
51 | | - |
52 | | -See our [directory](DIRECTORY.md) for easier navigation and a better overview of the project. |
| 1 | +# 🐍 The Algorithms - Python |
| 2 | + |
| 3 | +> **The definitive, open-source collection of all algorithms implemented in Python.** |
| 4 | +> |
| 5 | +> A collaborative educational project dedicated to providing clear, executable, and well-documented examples for fundamental and advanced computer science algorithms. |
| 6 | +
|
| 7 | +--- |
| 8 | + |
| 9 | +## 📈 Stats & Status |
| 10 | + |
| 11 | +| Metric | Status | |
| 12 | +| :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 13 | +| **Stars** | [](https://github.com/TheAlgorithms/Python/stargazers) | |
| 14 | +| **Forks** | [](https://github.com/TheAlgorithms/Python/network/members) | |
| 15 | +| **Contributors** | **1,250+** Active Community Members | |
| 16 | +| **License** | [](https://github.com/TheAlgorithms/Python/blob/master/LICENSE.md) | |
| 17 | +| **Code Style** | [](https://github.com/psf/black) | |
| 18 | +| **Ready-to-Code** | [](https://gitpod.io/#https://github.com/TheAlgorithms/Python) | |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## 🎯 Project Goals |
| 23 | + |
| 24 | +This repository is an invaluable resource for: |
| 25 | + |
| 26 | +- **Students:** To see working examples of algorithms learned in class. |
| 27 | +- **Developers:** To quickly reference or refresh knowledge on a specific implementation. |
| 28 | +- **Interview Preparation:** To practice and understand the underlying logic of common interview problems. |
| 29 | + |
| 30 | +**Our Core Philosophy:** **Clarity over Performance.** _Implementations prioritize readability and educational value. They are not optimized for production-grade speed._ |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## 📂 Repository Structure & Key Domains |
| 35 | + |
| 36 | +The project is meticulously organized into folders, each representing a core domain in computer science. |
| 37 | + |
| 38 | +| Domain | Example Topics | |
| 39 | +| :---------------------- | :--------------------------------------------------------------- | |
| 40 | +| **Data Structures** | Linked Lists, Trees, Heaps, Hash Maps | |
| 41 | +| **Searching & Sorting** | Binary Search, Bubble Sort, Merge Sort, Quickselect | |
| 42 | +| **Mathematics** | Number Theory, Prime Sieve, Matrix Operations, Geometry | |
| 43 | +| **Advanced CS** | Dynamic Programming, Greedy Methods, Divide and Conquer | |
| 44 | +| **Graph Theory** | BFS, DFS, Dijkstra's, Kruskal's, Network Flow | |
| 45 | +| **Security & Privacy** | Ciphers (Caesar, Vigenere), Hashes (SHA, MD5) | |
| 46 | +| **Modern Tech** | Machine Learning, Computer Vision, Blockchain, Quantum Computing | |
| 47 | + |
| 48 | +➡️ **Explore All Algorithms:** View the full, categorized list in our **[DIRECTORY.md](https://github.com/TheAlgorithms/Python/blob/master/DIRECTORY.md)**. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## 🛠️ Getting Started: Your First Run |
| 53 | + |
| 54 | +### Prerequisites |
| 55 | + |
| 56 | +- Python **3.8+** |
| 57 | +- (Optional but Recommended) A Python virtual environment. |
| 58 | + |
| 59 | +### Installation |
| 60 | + |
| 61 | +Clone the repository and install necessary dependencies: |
| 62 | + |
| 63 | +```bash |
| 64 | +# 1. Clone the repository |
| 65 | +git clone [https://github.com/TheAlgorithms/Python.git](https://github.com/TheAlgorithms/Python.git) |
| 66 | +cd Python |
| 67 | + |
| 68 | +# 2. Install dependencies (We recommend 'uv' for speed) |
| 69 | +# pip install uv |
| 70 | +# uv sync |
| 71 | + |
| 72 | +# OR using pip |
| 73 | +pip install -r requirements.txt |
| 74 | +Running an Example |
| 75 | +Algorithms are designed to be run directly for testing. Many include doctests for built-in verification. |
| 76 | + |
| 77 | +Bash |
| 78 | + |
| 79 | +# Example: Running the Fibonacci sequence algorithm |
| 80 | +python maths/fibonacci_sequence.py |
| 81 | + |
| 82 | +# Example: Running a Graph algorithm |
| 83 | +python graphs/depth_first_search.py |
| 84 | +``` |
| 85 | + |
| 86 | +# 🚀 Contribute and Grow |
| 87 | + |
| 88 | +This is a 100% community-driven project. Your contributions are the lifeblood of this repository! |
| 89 | + |
| 90 | +How to Get Involved |
| 91 | +Read the Guidelines: Start with the comprehensive CONTRIBUTING.md for a step-by-step guide. |
| 92 | + |
| 93 | +Find an Issue: Look for open issues labeled good first issue if you're new, or tackle a high-priority bug or missing algorithm. |
| 94 | + |
| 95 | +Submit a Pull Request (PR): Ensure your code is clean, well-commented, and adheres to the Black code style standard. |
| 96 | + |
| 97 | +Your contribution helps millions learn computer science! |
| 98 | + |
| 99 | +# 💬 Community & Support |
| 100 | + |
| 101 | +Need help, have a suggestion, or just want to discuss an algorithm? Join our vibrant community! |
| 102 | + |
| 103 | +Platform Link Purpose |
| 104 | +Discord Join our Server Real-time chat, quick help, and contribution coordination. |
| 105 | +Gitter Join our Chat General discussion and support channel. |
| 106 | + |
| 107 | +Export to Sheets |
| 108 | +⚠️ Important Disclaimer |
| 109 | +The code in this repository is designed for education and demonstration. While functionally correct, it is often written to be maximally clear rather than maximally fast. |
| 110 | + |
| 111 | +Do not use this code in a high-performance or production environment. For optimal performance in a production setting, rely on the optimized functions within Python's Standard Library or well-established third-party libraries. |
| 112 | + |
| 113 | +# © License |
| 114 | + |
| 115 | +This project is open source and available under the MIT License. |
0 commit comments