TheAlgorithms/Ruby
59.3
Weak · 20 September 2026
7.5k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is a Ruby-based educational library that implements a comprehensive collection of fundamental computer science algorithms and data structures. It provides concrete, tested implementations for core concepts including sorting, searching, graph traversal, dynamic programming, and various linear and non-linear data structures. Additionally, it includes utility modules for mathematical computations, unit conversions, and cryptographic ciphers, serving as a reference for algorithmic problem-solving and standard data structure usage.
How it got here
2017–2020 — comprehensive algorithm library expansion
11 changes.
This period focused on significantly expanding the project's algorithmic library by adding implementations for sorting, searching, and cryptographic algorithms. It also introduced new data structures such as AVL trees, tries, stacks, and queues, alongside utility scripts for number theory and array challenges.
2021–2023 — expansion of algorithmic library
13 changes.
This period focused on significantly expanding the Ruby algorithms library by adding comprehensive implementations for core data structures, including linked lists, hash tables, heaps, and graphs. It also introduced a wide array of algorithmic modules covering dynamic programming, backtracking, bit manipulation, and string processing, alongside practical utility scripts for mathematics, unit conversions, and electronics.
Features
Add AVL Tree, Binary Search Tree, and traversal utilities
The binary trees module now includes implementations for AVL trees (self-balancing) and standard Binary Search Trees, both supporting insertion, deletion, and key lookup. Additionally, standalone functions for preorder, inorder, and postorder traversals, as well as tree inversion, have been added to allow easy manipulation of binary tree structures.
_data\_structures/binary\trees · high confidence
Add Ruby implementations of singly, doubly, and circular linked lists
This change introduces three new Ruby source files in the \data\_structures/linked\_lists\ directory: \singly\_linked\_list.rb\, \doubly\_linked\_list.rb\, and \circular\_linked\_list.rb\. These files provide concrete implementations of the three primary linked list variants, including node definitions and core operations such as insertion at the head or tail, deletion, and traversal. The singly linked list includes \Enumerable\ support for iteration, while the doubly linked list adds bidirectional traversal and index-based access.
_data\_structures/linked\lists · high confidence
Add Stack data structure with overflow protection
A new Stack class has been added to the data structures library, implementing standard LIFO operations including push, pop, peek, empty?, full?, size, and contains?. The implementation includes a configurable size limit; attempting to push an element onto a full stack raises a StackOverflowError. The file also includes an example usage demonstrating the stack's behavior and error handling.
_data\structures/stacks · high confidence
Add Trie data structure for string prefix search
A new Trie (prefix tree) implementation has been added to the data structures library, enabling efficient lookup of words and patterns based on prefixes. This feature allows users to insert multiple words and check for the existence of specific strings or prefixes within the trie, leveraging O(max(search\_string, length of longest word)) lookup time.
_data\structures/tries · high confidence
Added Caesar, Merkle-Hellman, and RSA cipher implementations
The ciphers module now includes three new cryptographic algorithms: a Caesar Cipher for simple character shifting, a Merkle-Hellman cryptosystem based on the knapsack problem, and an RSA implementation using small primes for key generation. These additions expand the available encryption and decryption capabilities within the application.
ciphers · high confidence
Added Circular Queue and Array-based Queue implementations
This change introduces two new queue data structure implementations in the \data\_structures/queues\ directory. The \circular\_queue.rb\ file adds a \CircularQueue\ class that uses a fixed-size array to implement a ring buffer with O(1) enqueue and dequeue operations. The \queue.rb\ file adds an \ArrayQueue\ class that wraps Ruby's built-in Array methods (\unshift\ and \pop\) to provide a simple FIFO queue interface. Both files include usage examples demonstrating basic operations like adding items, peeking, and popping.
_data\structures/queues · high confidence
Added Disjoint Sets data structure implementation
A new Ruby implementation of the Disjoint Sets (Union-Find) data structure has been added to the repository. This includes a Node class for managing set elements with path compression and union by rank optimizations, along with a DisjointSets class providing make\_set, find\_set, and union\_set operations. The file also includes a basic usage example demonstrating set creation, union operations, and verification of set membership.
_data\_structures/disjoint\sets · high confidence
Added Euclidean GCD, Extended Euclidean GCD, and LCM algorithms
The discrete mathematics module now includes three new Ruby scripts for number theory calculations. Users can compute the Greatest Common Divisor using the standard Euclidean algorithm, the Extended Euclidean algorithm, and the Least Common Multiple (LCM) via a recursive GCD helper. Each script is self-contained with example outputs or interactive input prompts.
_discrete\mathematics · high confidence
Added Fisher-Yates shuffle and date difference calculation scripts
New utility scripts have been added to the 'other' directory: \fisher\_yates.rb\ implements the Fisher-Yates shuffle algorithm for randomizing arrays, and \number\_of\_days.rb\ calculates the number of days between two dates provided in YYYY-MM-DD format using Ruby's built-in Date.parse method.
other · high confidence
Added MaxHeap data structure
A new MaxHeap class has been introduced in the data structures library, providing an array-backed implementation of a max-heap. Users can now create heaps from initial collections, retrieve the maximum element, extract the maximum value, insert new elements, and check if the heap is empty. The implementation includes unit tests to verify core functionality such as array representation, empty state checks, and element extraction.
_data\structures/heaps · high confidence
Added Ohm's Law voltage calculator
A new Ruby script has been added to the electronics module that calculates voltage based on current and resistance using the formula V = I \* R. The tool validates that both input values are positive numbers and returns the calculated voltage in volts, or displays an error message if invalid inputs (such as negative values or non-numeric types) are provided.
electronics · high confidence
Added backtracking solution for generating well-formed parentheses
A new Ruby implementation for generating all combinations of well-formed parentheses has been added to the backtracking module. The solution uses a recursive backtracking approach that tracks the count of open and closing brackets to ensure validity at each step, supporting inputs up to n=8 pairs.
backtracking · high confidence
Added hash table algorithm solutions for common coding challenges
The hash table section now includes new Ruby implementations for several algorithmic problems, providing users with hash-based approaches to solve tasks such as Two Sum, Anagram Checking, Fizz Buzz, Good Pairs, Isomorphic Strings, and finding duplicates or uncommon words. These additions expand the available solution strategies within the data structures library.
_data\_structures/hash\table · high confidence
Added string manipulation challenge solutions
New solution files have been added to the data\_structures/arrays/strings directory, providing implementations for several string challenges. These include an almost palindrome checker using a two-pointer approach, an anagram checker using sort-and-compare logic, a jewels-and-stones counter with both brute-force and hash-based approaches, a valid palindrome checker offering three methods (reverse, reversed array, and two pointers), and a remove-vowels utility with brute-force, regex, and delete-method implementations.
_data\structures/arrays/strings · high confidence
Added temperature and weight conversion utilities
New Ruby modules have been introduced to handle unit conversions. The TemperatureConversion module provides bidirectional conversion between Celsius, Fahrenheit, and Kelvin, including error handling for invalid inputs. The WeightConversion module adds support for converting between kilograms, grams, pounds, and ounces, with specific validation to ensure integer inputs for certain operations.
conversions · high confidence
Expanded sorting algorithm library with new implementations and standardized testing
The sorting module has been significantly expanded with the addition of numerous new sorting algorithm implementations, including bead sort, binary insertion sort, bogo sort, cocktail sort, comb sort, gnome sort, heap sort, pancake sort, and radix sort, alongside existing ones like bubble, insertion, merge, quick, selection, shell, and bucket sorts. To support this growth, a shared \SortTests\ module was introduced to standardize test cases across all algorithms, ensuring consistent validation for sorted, reversed, and edge-case inputs. Additionally, a specific \sort\_colors\ implementation was added to handle in-place sorting of arrays containing only 0s, 1s, and 2s.
sorting · high confidence
Introduction of Project Euler problem solutions
Added a new collection of Ruby solutions for Project Euler problems (specifically problems 1, 2, 3, 4, 5, 6, 7, 10, 14, 20, and 21) along with a README outlining coding guidelines and a data file for problem 22. This introduces a new directory structure and set of algorithms for users to explore mathematical programming challenges.
_project\euler · high confidence
New array algorithm challenges and solutions added
The data\_structures/arrays directory now includes implementations for a wide range of array-based algorithmic challenges. New files cover problems such as 3Sum, Add Digits, finding duplicates, highest altitude, Fizz Buzz, products of other elements, good pairs, array intersections, maximum 69 number, maximum product/sum subarrays, next greater element, removing elements, richest customer wealth, shortest word distance, shuffling arrays, single number, sorted squares, and two-sum variants. Each file provides multiple solution approaches (e.g., brute force, hash maps, two pointers, dynamic programming) with complexity analysis and example usage.
_data\structures/arrays · high confidence
New bit manipulation algorithms and utilities added
The bit\_manipulation module now includes several new Ruby scripts for common bitwise operations. Users can now check if a number is a power of two, perform binary AND, OR, and XOR operations with string-based binary output, count set bits and trailing zeroes, and manipulate individual bits (set, clear, flip, check) at specific positions. All functions include input validation to ensure positive integers or non-negative positions as appropriate.
_bit\manipulation · high confidence
New dynamic programming algorithms added to the library
The dynamic\_programming module now includes implementations for several classic algorithmic problems: climbing stairs, coin change (minimum coins and combinations), counting sorted vowel strings, edit distance (with unit tests), Fibonacci numbers, house robber (both recursive and optimized iterative approaches), 0-1 knapsack (with unit tests), ones and zeros (largest subset with limited 0s and 1s), and Pascal's triangle row retrieval (brute force, standard DP, and memory-efficient DP). These additions provide users with ready-to-use solutions for common dynamic programming challenges, some accompanied by test cases to verify correctness.
_dynamic\programming · high confidence
New graph data structures and algorithms
Added support for unweighted and weighted graphs (both directed and undirected) via the UnweightedGraph and WeightedGraph classes, along with a Breadth-First Search (BFS) implementation that tracks visited nodes, distances, and parents, and supports optional callbacks for when nodes are seen or fully visited. Also introduced a TopologicalSorter for directed acyclic graphs that returns a valid linear ordering and raises an error for cycles or undirected inputs.
_data\structures/graphs · high confidence
New mathematical algorithms and utilities added to the maths library
The maths directory now includes a comprehensive set of new Ruby scripts and tests for various mathematical operations. Users can now calculate absolute values, absolute maximums/minimums, sums, averages, and medians. Additional features include algorithms for prime number checking, factorial computation (iterative and non-iterative), Fibonacci and Lucas series (using Binet's formula), Armstrong numbers, palindromes, and power-of-two detection. The update also adds number base conversions (binary/decimal), Roman numeral conversion, digital root calculations, and specific sequence generators like Pascal's triangle rows and sorted vowel strings. Input validation and error handling have been implemented across these new tools.
maths · high confidence
New search algorithms and utilities added to the library
The searches module has been expanded with several new algorithm implementations: binary search, depth-first search (for graph traversal), double linear search, Fibonacci search, interpolation search (with input validation and tests), jump search, linear search, recursive double linear search, recursive linear search, ternary search, and a number-of-islands solver using DFS. These additions provide users with a broader set of tools for searching arrays and traversing graphs, including both iterative and recursive variants, as well as specialized algorithms for sorted and unsorted data structures.
searches · high confidence
New string algorithms: Boyer-Moore-Horspool search, Hamming distance, and top-k frequent words
The strings module now includes three new algorithmic capabilities. Users can perform efficient substring searches using the Boyer-Moore-Horspool algorithm, which supports finding the first match or all match indices. A Hamming distance function is available to calculate the difference between two strings of equal length, raising an error for mismatched lengths. Additionally, a new function retrieves the k most frequent words from a list using a max-heap, returning them in non-increasing order of frequency.
strings · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 59.
Lenses
- Code Health 99
- Architecture 100
- Maturity 43
- Readiness 57
- Security 84
Changes since last survey
- 300 commits — 286 feature/other, 14 fixes
By area
- (repo) — 91 commits
- (root) — 87 commits
- data_structures/arrays — 16 commits
- .github/workflows — 12 commits
- data_structures/hash_table — 8 commits
- data_structures/graphs — 7 commits
- dynamic_programming/pascal_triangle_ii.rb — 6 commits
- project_euler/problem_007 — 5 commits
- project_euler/problem_010 — 4 commits
- conversions/weight_conversions.rb — 3 commits
- other/number_of_days.rb — 3 commits
- .idea/misc.xml — 2 commits
- bit_manipulation/binary_and_operator.rb — 2 commits
- ciphers/caesar.rb — 2 commits
- data_structures/binary_trees — 2 commits
- data_structures/disjoint_sets — 2 commits
- data_structures/heaps — 2 commits
- data_structures/queues — 2 commits
- dynamic_programming/climbing_stairs.rb — 2 commits
- dynamic_programming/count_sorted_vowel_strings.rb — 2 commits
Notable commits
- fix: Fix duplicate test class names in sorting tests
- fix: Fix lint
- fix: Fix return value in interpolation search for zero value range
- fix: Fix the complexity memoisation check
- fix: Merge pull request #211 from TheAlgorithms/quick-fix-update_directory_md
- fix: Merge pull request #230 from vzvu3k6k/fix/sorting-test-class-names
- fix: Minor fixes
- fix: Revert "remove project_euler"
- fix: Temporarily revert "Merge pull request #209 from Panquesito7/scripts_workflow"
- fix: fix directory.md
- fix: fix duplication
- fix: fix lint
- fix: fix: use GITHUB_ACTOR in git config
- fix: fixed importing issue
- change: 3n plus 1 feature implementation
- change: Add Caesar
- change: Add Date.parse solution
- change: Add Discord badge in README.md
- change: Add array solutions with descriptions
- change: Add binary insertion sort
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
TheAlgorithms/Ruby was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit bda11bdfd83b7958e1ca98247e5e43100ca88865 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.