Full Code of TheAlgorithms/Rust for AI

master 867330513179 cached
438 files
1.8 MB
563.5k tokens
3217 symbols
1 requests
Download .txt
Showing preview only (2,011K chars total). Download the full file or copy to clipboard to get everything.
Repository: TheAlgorithms/Rust
Branch: master
Commit: 867330513179
Files: 438
Total size: 1.8 MB

Directory structure:
gitextract_gs1_le18/

├── .gitconfig
├── .github/
│   ├── CODEOWNERS
│   ├── dependabot.yml
│   ├── pull_request_template.md
│   └── workflows/
│       ├── build.yml
│       ├── code_ql.yml
│       ├── directory_workflow.yml
│       ├── scripts/
│       │   └── build_directory/
│       │       ├── Cargo.toml
│       │       └── src/
│       │           ├── lib.rs
│       │           └── main.rs
│       ├── stale.yml
│       └── upload_coverage_report.yml
├── .gitignore
├── .gitpod.Dockerfile
├── .gitpod.yml
├── CONTRIBUTING.md
├── Cargo.toml
├── DIRECTORY.md
├── LICENSE
├── README.md
├── clippy.toml
├── git_hooks/
│   └── pre-commit
└── src/
    ├── backtracking/
    │   ├── all_combination_of_size_k.rs
    │   ├── graph_coloring.rs
    │   ├── hamiltonian_cycle.rs
    │   ├── knight_tour.rs
    │   ├── mod.rs
    │   ├── n_queens.rs
    │   ├── parentheses_generator.rs
    │   ├── permutations.rs
    │   ├── rat_in_maze.rs
    │   ├── subset_sum.rs
    │   └── sudoku.rs
    ├── big_integer/
    │   ├── fast_factorial.rs
    │   ├── mod.rs
    │   ├── multiply.rs
    │   └── poly1305.rs
    ├── bit_manipulation/
    │   ├── binary_coded_decimal.rs
    │   ├── binary_count_trailing_zeros.rs
    │   ├── binary_shifts.rs
    │   ├── counting_bits.rs
    │   ├── find_missing_number.rs
    │   ├── find_previous_power_of_two.rs
    │   ├── find_unique_number.rs
    │   ├── hamming_distance.rs
    │   ├── highest_set_bit.rs
    │   ├── is_power_of_two.rs
    │   ├── mod.rs
    │   ├── n_bits_gray_code.rs
    │   ├── reverse_bits.rs
    │   ├── rightmost_set_bit.rs
    │   ├── sum_of_two_integers.rs
    │   ├── swap_odd_even_bits.rs
    │   └── twos_complement.rs
    ├── ciphers/
    │   ├── README.md
    │   ├── aes.rs
    │   ├── affine_cipher.rs
    │   ├── another_rot13.rs
    │   ├── baconian_cipher.rs
    │   ├── base16.rs
    │   ├── base32.rs
    │   ├── base64.rs
    │   ├── base85.rs
    │   ├── blake2b.rs
    │   ├── caesar.rs
    │   ├── chacha.rs
    │   ├── diffie_hellman.rs
    │   ├── hashing_traits.rs
    │   ├── hill_cipher.rs
    │   ├── kernighan.rs
    │   ├── mod.rs
    │   ├── morse_code.rs
    │   ├── polybius.rs
    │   ├── rail_fence.rs
    │   ├── rot13.rs
    │   ├── rsa_cipher.rs
    │   ├── salsa.rs
    │   ├── sha256.rs
    │   ├── sha3.rs
    │   ├── tea.rs
    │   ├── theoretical_rot13.rs
    │   ├── transposition.rs
    │   ├── trifid.rs
    │   ├── vernam.rs
    │   ├── vigenere.rs
    │   └── xor.rs
    ├── compression/
    │   ├── burrows_wheeler_transform.rs
    │   ├── huffman_encoding.rs
    │   ├── lz77.rs
    │   ├── mod.rs
    │   ├── move_to_front.rs
    │   └── run_length_encoding.rs
    ├── conversions/
    │   ├── binary_to_decimal.rs
    │   ├── binary_to_hexadecimal.rs
    │   ├── binary_to_octal.rs
    │   ├── decimal_to_binary.rs
    │   ├── decimal_to_hexadecimal.rs
    │   ├── decimal_to_octal.rs
    │   ├── energy.rs
    │   ├── hexadecimal_to_binary.rs
    │   ├── hexadecimal_to_decimal.rs
    │   ├── hexadecimal_to_octal.rs
    │   ├── ipv4_conversion.rs
    │   ├── length_conversion.rs
    │   ├── mod.rs
    │   ├── octal_to_binary.rs
    │   ├── octal_to_decimal.rs
    │   ├── octal_to_hexadecimal.rs
    │   ├── order_of_magnitude_conversion.rs
    │   ├── pressure.rs
    │   ├── rectangular_to_polar.rs
    │   ├── rgb_cmyk_conversion.rs
    │   ├── rgb_hsv_conversion.rs
    │   ├── roman_numerals.rs
    │   ├── speed.rs
    │   ├── temperature.rs
    │   ├── time.rs
    │   ├── volume.rs
    │   └── weight.rs
    ├── data_structures/
    │   ├── README.md
    │   ├── avl_tree.rs
    │   ├── b_tree.rs
    │   ├── binary_search_tree.rs
    │   ├── fenwick_tree.rs
    │   ├── floyds_algorithm.rs
    │   ├── graph.rs
    │   ├── hash_table.rs
    │   ├── heap.rs
    │   ├── lazy_segment_tree.rs
    │   ├── linked_list.rs
    │   ├── mod.rs
    │   ├── probabilistic/
    │   │   ├── bloom_filter.rs
    │   │   ├── count_min_sketch.rs
    │   │   └── mod.rs
    │   ├── queue.rs
    │   ├── range_minimum_query.rs
    │   ├── rb_tree.rs
    │   ├── segment_tree.rs
    │   ├── segment_tree_recursive.rs
    │   ├── skip_list.rs
    │   ├── stack_using_singly_linked_list.rs
    │   ├── treap.rs
    │   ├── trie.rs
    │   ├── union_find.rs
    │   └── veb_tree.rs
    ├── dynamic_programming/
    │   ├── catalan_numbers.rs
    │   ├── coin_change.rs
    │   ├── egg_dropping.rs
    │   ├── fibonacci.rs
    │   ├── fractional_knapsack.rs
    │   ├── integer_partition.rs
    │   ├── is_subsequence.rs
    │   ├── knapsack.rs
    │   ├── longest_common_subsequence.rs
    │   ├── longest_common_substring.rs
    │   ├── longest_continuous_increasing_subsequence.rs
    │   ├── longest_increasing_subsequence.rs
    │   ├── matrix_chain_multiply.rs
    │   ├── maximal_square.rs
    │   ├── maximum_subarray.rs
    │   ├── minimum_cost_path.rs
    │   ├── mod.rs
    │   ├── optimal_bst.rs
    │   ├── palindrome_partitioning.rs
    │   ├── rod_cutting.rs
    │   ├── smith_waterman.rs
    │   ├── snail.rs
    │   ├── subset_generation.rs
    │   ├── subset_sum.rs
    │   ├── task_assignment.rs
    │   ├── trapped_rainwater.rs
    │   └── word_break.rs
    ├── financial/
    │   ├── depreciation.rs
    │   ├── equated_monthly_installments.rs
    │   ├── exponential_moving_average.rs
    │   ├── finance_ratios.rs
    │   ├── interest.rs
    │   ├── mod.rs
    │   ├── npv.rs
    │   ├── npv_sensitivity.rs
    │   ├── payback.rs
    │   ├── present_value.rs
    │   └── treynor_ratio.rs
    ├── general/
    │   ├── convex_hull.rs
    │   ├── fisher_yates_shuffle.rs
    │   ├── genetic.rs
    │   ├── hanoi.rs
    │   ├── huffman_encoding.rs
    │   ├── kadane_algorithm.rs
    │   ├── kmeans.rs
    │   ├── mex.rs
    │   ├── mod.rs
    │   ├── permutations/
    │   │   ├── heap.rs
    │   │   ├── mod.rs
    │   │   ├── naive.rs
    │   │   └── steinhaus_johnson_trotter.rs
    │   ├── subarray_sum_equals_k.rs
    │   └── two_sum.rs
    ├── geometry/
    │   ├── closest_points.rs
    │   ├── graham_scan.rs
    │   ├── jarvis_scan.rs
    │   ├── mod.rs
    │   ├── point.rs
    │   ├── polygon_points.rs
    │   ├── ramer_douglas_peucker.rs
    │   └── segment.rs
    ├── graph/
    │   ├── ant_colony_optimization.rs
    │   ├── astar.rs
    │   ├── bellman_ford.rs
    │   ├── bipartite_matching.rs
    │   ├── breadth_first_search.rs
    │   ├── centroid_decomposition.rs
    │   ├── decremental_connectivity.rs
    │   ├── depth_first_search.rs
    │   ├── depth_first_search_tic_tac_toe.rs
    │   ├── detect_cycle.rs
    │   ├── dijkstra.rs
    │   ├── dinic_maxflow.rs
    │   ├── disjoint_set_union.rs
    │   ├── eulerian_path.rs
    │   ├── floyd_warshall.rs
    │   ├── ford_fulkerson.rs
    │   ├── graph_enumeration.rs
    │   ├── heavy_light_decomposition.rs
    │   ├── kosaraju.rs
    │   ├── lee_breadth_first_search.rs
    │   ├── lowest_common_ancestor.rs
    │   ├── minimum_spanning_tree.rs
    │   ├── mod.rs
    │   ├── prim.rs
    │   ├── prufer_code.rs
    │   ├── strongly_connected_components.rs
    │   ├── tarjans_ssc.rs
    │   ├── topological_sort.rs
    │   └── two_satisfiability.rs
    ├── greedy/
    │   ├── minimum_coin_change.rs
    │   ├── mod.rs
    │   ├── smallest_range.rs
    │   └── stable_matching.rs
    ├── lib.rs
    ├── machine_learning/
    │   ├── cholesky.rs
    │   ├── decision_tree.rs
    │   ├── k_means.rs
    │   ├── k_nearest_neighbors.rs
    │   ├── linear_regression.rs
    │   ├── logistic_regression.rs
    │   ├── loss_function/
    │   │   ├── average_margin_ranking_loss.rs
    │   │   ├── hinge_loss.rs
    │   │   ├── huber_loss.rs
    │   │   ├── kl_divergence_loss.rs
    │   │   ├── mean_absolute_error_loss.rs
    │   │   ├── mean_squared_error_loss.rs
    │   │   ├── mod.rs
    │   │   └── negative_log_likelihood.rs
    │   ├── mod.rs
    │   ├── naive_bayes.rs
    │   ├── optimization/
    │   │   ├── adam.rs
    │   │   ├── gradient_descent.rs
    │   │   ├── mod.rs
    │   │   └── momentum.rs
    │   ├── perceptron.rs
    │   ├── principal_component_analysis.rs
    │   ├── random_forest.rs
    │   └── support_vector_classifier.rs
    ├── math/
    │   ├── abs.rs
    │   ├── aliquot_sum.rs
    │   ├── amicable_numbers.rs
    │   ├── area_of_polygon.rs
    │   ├── area_under_curve.rs
    │   ├── armstrong_number.rs
    │   ├── average.rs
    │   ├── baby_step_giant_step.rs
    │   ├── bell_numbers.rs
    │   ├── binary_exponentiation.rs
    │   ├── binomial_coefficient.rs
    │   ├── catalan_numbers.rs
    │   ├── ceil.rs
    │   ├── chinese_remainder_theorem.rs
    │   ├── collatz_sequence.rs
    │   ├── combinations.rs
    │   ├── cross_entropy_loss.rs
    │   ├── decimal_to_fraction.rs
    │   ├── doomsday.rs
    │   ├── elliptic_curve.rs
    │   ├── euclidean_distance.rs
    │   ├── exponential_linear_unit.rs
    │   ├── extended_euclidean_algorithm.rs
    │   ├── factorial.rs
    │   ├── factors.rs
    │   ├── fast_fourier_transform.rs
    │   ├── fast_power.rs
    │   ├── faster_perfect_numbers.rs
    │   ├── field.rs
    │   ├── frizzy_number.rs
    │   ├── gaussian_elimination.rs
    │   ├── gaussian_error_linear_unit.rs
    │   ├── gcd_of_n_numbers.rs
    │   ├── geometric_series.rs
    │   ├── greatest_common_divisor.rs
    │   ├── huber_loss.rs
    │   ├── infix_to_postfix.rs
    │   ├── interest.rs
    │   ├── interpolation.rs
    │   ├── interquartile_range.rs
    │   ├── karatsuba_multiplication.rs
    │   ├── lcm_of_n_numbers.rs
    │   ├── leaky_relu.rs
    │   ├── least_square_approx.rs
    │   ├── linear_sieve.rs
    │   ├── logarithm.rs
    │   ├── lucas_series.rs
    │   ├── matrix_ops.rs
    │   ├── mersenne_primes.rs
    │   ├── miller_rabin.rs
    │   ├── mod.rs
    │   ├── modular_exponential.rs
    │   ├── newton_raphson.rs
    │   ├── nthprime.rs
    │   ├── pascal_triangle.rs
    │   ├── perfect_cube.rs
    │   ├── perfect_numbers.rs
    │   ├── perfect_square.rs
    │   ├── pollard_rho.rs
    │   ├── postfix_evaluation.rs
    │   ├── prime_check.rs
    │   ├── prime_factors.rs
    │   ├── prime_numbers.rs
    │   ├── quadratic_residue.rs
    │   ├── random.rs
    │   ├── relu.rs
    │   ├── sieve_of_eratosthenes.rs
    │   ├── sigmoid.rs
    │   ├── signum.rs
    │   ├── simpsons_integration.rs
    │   ├── softmax.rs
    │   ├── sprague_grundy_theorem.rs
    │   ├── square_pyramidal_numbers.rs
    │   ├── square_root.rs
    │   ├── sum_of_digits.rs
    │   ├── sum_of_geometric_progression.rs
    │   ├── sum_of_harmonic_series.rs
    │   ├── sylvester_sequence.rs
    │   ├── tanh.rs
    │   ├── trapezoidal_integration.rs
    │   ├── trial_division.rs
    │   ├── trig_functions.rs
    │   ├── vector_cross_product.rs
    │   └── zellers_congruence_algorithm.rs
    ├── navigation/
    │   ├── bearing.rs
    │   ├── haversine.rs
    │   ├── mod.rs
    │   └── rhumbline.rs
    ├── number_theory/
    │   ├── compute_totient.rs
    │   ├── euler_totient.rs
    │   ├── kth_factor.rs
    │   └── mod.rs
    ├── searching/
    │   ├── README.md
    │   ├── binary_search.rs
    │   ├── binary_search_recursive.rs
    │   ├── exponential_search.rs
    │   ├── fibonacci_search.rs
    │   ├── interpolation_search.rs
    │   ├── jump_search.rs
    │   ├── kth_smallest.rs
    │   ├── kth_smallest_heap.rs
    │   ├── linear_search.rs
    │   ├── mod.rs
    │   ├── moore_voting.rs
    │   ├── quick_select.rs
    │   ├── saddleback_search.rs
    │   ├── ternary_search.rs
    │   ├── ternary_search_min_max.rs
    │   ├── ternary_search_min_max_recursive.rs
    │   └── ternary_search_recursive.rs
    ├── signal_analysis/
    │   ├── mod.rs
    │   └── yin.rs
    ├── sorting/
    │   ├── README.md
    │   ├── bead_sort.rs
    │   ├── binary_insertion_sort.rs
    │   ├── bingo_sort.rs
    │   ├── bitonic_sort.rs
    │   ├── bogo_sort.rs
    │   ├── bubble_sort.rs
    │   ├── bucket_sort.rs
    │   ├── cocktail_shaker_sort.rs
    │   ├── comb_sort.rs
    │   ├── counting_sort.rs
    │   ├── cycle_sort.rs
    │   ├── dutch_national_flag_sort.rs
    │   ├── exchange_sort.rs
    │   ├── gnome_sort.rs
    │   ├── heap_sort.rs
    │   ├── insertion_sort.rs
    │   ├── intro_sort.rs
    │   ├── merge_sort.rs
    │   ├── mod.rs
    │   ├── odd_even_sort.rs
    │   ├── pancake_sort.rs
    │   ├── patience_sort.rs
    │   ├── pigeonhole_sort.rs
    │   ├── quick_sort.rs
    │   ├── quick_sort_3_ways.rs
    │   ├── radix_sort.rs
    │   ├── selection_sort.rs
    │   ├── shell_sort.rs
    │   ├── sleep_sort.rs
    │   ├── sort_utils.rs
    │   ├── stooge_sort.rs
    │   ├── tim_sort.rs
    │   ├── tree_sort.rs
    │   ├── wave_sort.rs
    │   └── wiggle_sort.rs
    └── string/
        ├── README.md
        ├── aho_corasick.rs
        ├── anagram.rs
        ├── autocomplete_using_trie.rs
        ├── boyer_moore_search.rs
        ├── burrows_wheeler_transform.rs
        ├── duval_algorithm.rs
        ├── hamming_distance.rs
        ├── isogram.rs
        ├── isomorphism.rs
        ├── jaro_winkler_distance.rs
        ├── knuth_morris_pratt.rs
        ├── levenshtein_distance.rs
        ├── lipogram.rs
        ├── manacher.rs
        ├── mod.rs
        ├── palindrome.rs
        ├── pangram.rs
        ├── rabin_karp.rs
        ├── reverse.rs
        ├── run_length_encoding.rs
        ├── shortest_palindrome.rs
        ├── suffix_array.rs
        ├── suffix_array_manber_myers.rs
        ├── suffix_tree.rs
        └── z_algorithm.rs

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitconfig
================================================
[core]
    hooksPath = git_hooks


================================================
FILE: .github/CODEOWNERS
================================================
* @imp2002


================================================
FILE: .github/dependabot.yml
================================================
---
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/.github/workflows/"
    schedule:
      interval: "weekly"

  - package-ecosystem: "cargo"
    directory: "/"
    schedule:
      interval: "daily"
...


================================================
FILE: .github/pull_request_template.md
================================================
# Pull Request Template

## Description

Please include a summary of the change and which issue (if any) is fixed.
A brief description of the algorithm and your implementation method can be helpful too. If the implemented method/algorithm is not so
well-known, it would be helpful to add a link to an article explaining it with more details.

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:

- [ ] I ran bellow commands using the latest version of **rust nightly**.
- [ ] I ran `cargo clippy --all -- -D warnings` just before my last commit and fixed any issue that was found.
- [ ] I ran `cargo fmt` just before my last commit.
- [ ] I ran `cargo test` just before my last commit and all tests passed.
- [ ] I added my algorithm to the corresponding `mod.rs` file within its own folder, and in any parent folder(s).
- [ ] I added my algorithm to `DIRECTORY.md` with the correct link.
- [ ] I checked `COUNTRIBUTING.md` and my code follows its guidelines.

Please make sure that if there is a test that takes too long to run ( > 300ms), you `#[ignore]` that or
try to optimize your code or make the test easier to run. We have this rule because we have hundreds of
tests to run; If each one of them took 300ms, we would have to wait for a long time.


================================================
FILE: .github/workflows/build.yml
================================================
name: build

'on':
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '51 2 * * 4'

permissions:
  contents: read

jobs:
  fmt:
    name: cargo fmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
    - name: cargo fmt
      run: cargo fmt --all -- --check

  clippy:
    name: cargo clippy
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
    - name: cargo clippy
      run: cargo clippy --all --all-targets -- -D warnings

  test:
    name: cargo test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
    - name: cargo test
      run: cargo test


================================================
FILE: .github/workflows/code_ql.yml
================================================
---
name: code_ql

'on':
  workflow_dispatch:
  push:
    branches:
      - master
  pull_request:
  schedule:
    - cron: '10 7 * * 1'

jobs:
  analyze:
    name: Analyze
    runs-on: 'ubuntu-latest'
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language:
          - actions
          - rust

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v4
        with:
          languages: ${{ matrix.language }}
          build-mode: none

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v4
        with:
          category: "/language:${{matrix.language}}"
...


================================================
FILE: .github/workflows/directory_workflow.yml
================================================
name: build_directory_md
on:
  push:
    branches: [master]

permissions:
  contents: read

jobs:
  MainSequence:
    name: DIRECTORY.md
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v6
      - name: Setup Git Specs
        run: |
          git config --global user.name "$GITHUB_ACTOR"
          git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
      - name: Update DIRECTORY.md
        run: |
         cargo run --manifest-path=.github/workflows/scripts/build_directory/Cargo.toml
      - name: Commit DIRECTORY.md
        run: |
         git add DIRECTORY.md
         git commit -m "Update DIRECTORY.md [skip actions]" ||  true
         git push origin HEAD:$GITHUB_REF || true


================================================
FILE: .github/workflows/scripts/build_directory/Cargo.toml
================================================
[package]
name = "build_directory"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]


================================================
FILE: .github/workflows/scripts/build_directory/src/lib.rs
================================================
use std::{
    error::Error,
    fs,
    path::{Path, PathBuf},
};

static URL_BASE: &str = "https://github.com/TheAlgorithms/Rust/blob/master";

fn good_filepaths(top_dir: &Path) -> Result<Vec<String>, Box<dyn Error>> {
    let mut good_fs = Vec::new();
    if top_dir.is_dir() {
        for entry in fs::read_dir(top_dir)? {
            let entry = entry?;
            let path = entry.path();
            if entry.file_name().to_str().unwrap().starts_with('.')
                || entry.file_name().to_str().unwrap().starts_with('_')
            {
                continue;
            }
            if path.is_dir() {
                let mut other = good_filepaths(&path)?;
                good_fs.append(&mut other);
            } else if entry.file_name().to_str().unwrap().ends_with(".rs")
                && entry.file_name().to_str().unwrap() != "mod.rs"
            {
                good_fs.push(
                    path.into_os_string()
                        .into_string()
                        .unwrap()
                        .split_at(2)
                        .1
                        .to_string(),
                );
            }
        }
    }
    good_fs.sort();
    Ok(good_fs)
}

fn md_prefix(indent_count: usize) -> String {
    if indent_count > 0 {
        format!("{}*", "  ".repeat(indent_count))
    } else {
        "\n##".to_string()
    }
}

fn print_path(old_path: String, new_path: String) -> (String, String) {
    let old_parts = old_path
        .split(std::path::MAIN_SEPARATOR)
        .collect::<Vec<&str>>();
    let mut result = String::new();
    for (count, new_part) in new_path.split(std::path::MAIN_SEPARATOR).enumerate() {
        if count + 1 > old_parts.len() || old_parts[count] != new_part {
            println!("{} {}", md_prefix(count), to_title(new_part));
            result.push_str(format!("{} {}\n", md_prefix(count), to_title(new_part)).as_str());
        }
    }
    (new_path, result)
}

pub fn build_directory_md(top_dir: &Path) -> Result<String, Box<dyn Error>> {
    let mut old_path = String::from("");
    let mut result = String::new();
    for filepath in good_filepaths(top_dir)? {
        let mut filepath = PathBuf::from(filepath);
        let filename = filepath.file_name().unwrap().to_owned();
        filepath.pop();
        let filepath = filepath.into_os_string().into_string().unwrap();
        if filepath != old_path {
            let path_res = print_path(old_path, filepath);
            old_path = path_res.0;
            result.push_str(path_res.1.as_str());
        }
        let url = format!("{}/{}", old_path, filename.to_string_lossy());
        let url = get_addr(&url);
        let indent = old_path.matches(std::path::MAIN_SEPARATOR).count() + 1;
        let filename = to_title(filename.to_str().unwrap().split('.').collect::<Vec<&str>>()[0]);
        println!("{} [{}]({})", md_prefix(indent), filename, url);
        result.push_str(format!("{} [{}]({})\n", md_prefix(indent), filename, url).as_str());
    }
    Ok(result)
}

fn to_title(name: &str) -> String {
    let mut change = true;
    name.chars()
        .map(move |letter| {
            if change && !letter.is_numeric() {
                change = false;
                letter.to_uppercase().next().unwrap()
            } else if letter == '_' {
                change = true;
                ' '
            } else {
                if letter.is_numeric() || !letter.is_alphanumeric() {
                    change = true;
                }
                letter
            }
        })
        .collect::<String>()
}

fn get_addr(addr: &str) -> String {
    if cfg!(windows) {
        format!("{}/{}", URL_BASE, switch_backslash(addr))
    } else {
        format!("{}/{}", URL_BASE, addr)
    }
}

// Function that changes '\' to '/' (for Windows builds only)
fn switch_backslash(addr: &str) -> String {
    addr.chars()
        .map(|mut symbol| {
            if symbol == '\\' {
                symbol = '/';
            }
            symbol
        })
        .collect::<String>()
}


================================================
FILE: .github/workflows/scripts/build_directory/src/main.rs
================================================
use std::{fs::File, io::Write, path::Path};

use build_directory::build_directory_md;
fn main() -> Result<(), std::io::Error> {
    let mut file = File::create("DIRECTORY.md").unwrap(); // unwrap for panic

    match build_directory_md(Path::new(".")) {
        Ok(buf) => {
            file.write_all("# List of all files\n".as_bytes())?;
            file.write_all(buf.as_bytes())?;
        }
        Err(err) => {
            panic!("Error while creating string: {err}");
        }
    }
    Ok(())
}


================================================
FILE: .github/workflows/stale.yml
================================================
name: 'Close stale issues and PRs'
on:
  schedule:
    - cron: '0 0 * * *'
permissions:
  contents: read

jobs:
  stale:
    permissions:
      issues: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v10
        with:
          stale-issue-message: 'This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
          close-issue-message: 'Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel. Thank you for your contributions!'
          stale-pr-message: 'This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
          close-pr-message: 'Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel. Thank you for your contributions!'
          exempt-issue-labels: 'dont-close'
          exempt-pr-labels: 'dont-close'
          days-before-stale: 30
          days-before-close: 7


================================================
FILE: .github/workflows/upload_coverage_report.yml
================================================
---
name: upload_coverage_report

# yamllint disable-line rule:truthy
on:
  workflow_dispatch:
  push:
    branches:
      - master
  pull_request:

permissions:
  contents: read

env:
  REPORT_NAME: "lcov.info"

jobs:
  upload_coverage_report:
    runs-on: ubuntu-latest
    env:
      CARGO_TERM_COLOR: always
    steps:
      - uses: actions/checkout@v6
      - uses: taiki-e/install-action@cargo-llvm-cov
      - name: Generate code coverage
        run: >
          cargo llvm-cov
          --all-features
          --workspace
          --lcov
          --output-path "${{ env.REPORT_NAME }}"
      - name: Upload coverage to codecov (tokenless)
        if: >-
          github.event_name == 'pull_request' &&
          github.event.pull_request.head.repo.full_name != github.repository
        uses: codecov/codecov-action@v5
        with:
          files: "${{ env.REPORT_NAME }}"
          fail_ci_if_error: true
      - name: Upload coverage to codecov (with token)
        if: "! github.event.pull_request.head.repo.fork "
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: "${{ env.REPORT_NAME }}"
          fail_ci_if_error: true
...


================================================
FILE: .gitignore
================================================

/target
**/*.rs.bk

/target
**/*.rs.bk
Cargo.lock
/.idea/
.vscode


================================================
FILE: .gitpod.Dockerfile
================================================
FROM gitpod/workspace-rust:2024-06-05-14-45-28

USER gitpod


================================================
FILE: .gitpod.yml
================================================
---
image:
  file: .gitpod.Dockerfile

tasks:
  - init: cargo build

vscode:
  extensions:
    - rust-lang.rust-analyzer
...


================================================
FILE: CONTRIBUTING.md
================================================
# The Algorithms: Rust

This project aims at showcasing common algorithms implemented in `Rust`, with an accent on idiomatic code and genericity. 

## Project structure

The project is organized as follows:

`src/`
  - `my_algo_category/`
    - `mod.rs`
    - `my_algorithm.rs`
    - `some_other_algorithm.rs`
  - `some_other_algo_category/`
    - ...


`mod.rs` contains the export:

```rust
mod my_algorithm;

pub use self::my_algorithm::my_algorithm;
```

`my_algorithm.rs` contains your algorithm and the related tests:

```rust
pub fn my_algorithm() {
    // ...
}

#[cfg(test)]
mod tests {
    #[test]
    fn my_test() {
        // ...
    }
}
```

## Before submitting your PR

Do **not** use acronyms: `DFS` should be `depth_first_search`.

Make sure you run
  * `cargo test` 
  * `cargo fmt`
  * `cargo clippy --all -- -D warnings`

  And that's about it !


================================================
FILE: Cargo.toml
================================================
[package]
name = "the_algorithms_rust"
version = "0.1.0"
edition = "2021"
authors = ["Anshul Malik <malikanshul29@gmail.com>"]

[dependencies]
nalgebra = "0.34.0"
ndarray = "0.17.2"
num-bigint = { version = "0.4", optional = true }
num-traits = { version = "0.2", optional = true }
rand = "0.10"

[dev-dependencies]
quickcheck = "1.0"
quickcheck_macros = "1.0"

[features]
default = ["big-math"]
big-math = ["dep:num-bigint", "dep:num-traits"]

[lints.clippy]
cargo = "warn"
nursery = "warn"
pedantic = "warn"
restriction = "warn"
# cargo-lints:
cargo_common_metadata = { level = "allow", priority = 1 }
multiple_crate_versions = { level = "allow", priority = 1 }
# complexity-lints:
manual_div_ceil = { level = "allow", priority = 1 }
precedence = { level = "allow", priority = 1 }
# nursery-lints:
branches_sharing_code = { level = "allow", priority = 1 }
cognitive_complexity = { level = "allow", priority = 1 }
derive_partial_eq_without_eq = { level = "allow", priority = 1 }
empty_line_after_doc_comments = { level = "allow", priority = 1 }
fallible_impl_from = { level = "allow", priority = 1 }
imprecise_flops = { level = "allow", priority = 1 }
missing_const_for_fn = { level = "allow", priority = 1 }
nonstandard_macro_braces = { level = "allow", priority = 1 }
option_if_let_else = { level = "allow", priority = 1 }
suboptimal_flops = { level = "allow", priority = 1 }
suspicious_operation_groupings = { level = "allow", priority = 1 }
too_long_first_doc_paragraph = { level = "allow", priority = 1 }
use_self = { level = "allow", priority = 1 }
while_float = { level = "allow", priority = 1 }
# pedantic-lints:
cast_lossless = { level = "allow", priority = 1 }
cast_possible_truncation = { level = "allow", priority = 1 }
cast_possible_wrap = { level = "allow", priority = 1 }
cast_precision_loss = { level = "allow", priority = 1 }
cast_sign_loss = { level = "allow", priority = 1 }
cloned_instead_of_copied = { level = "allow", priority = 1 }
doc_markdown = { level = "allow", priority = 1 }
explicit_deref_methods = { level = "allow", priority = 1 }
explicit_iter_loop = { level = "allow", priority = 1 }
float_cmp = { level = "allow", priority = 1 }
ignore_without_reason = { level = "allow", priority = 1 }
implicit_clone = { level = "allow", priority = 1 }
implicit_hasher = { level = "allow", priority = 1 }
items_after_statements = { level = "allow", priority = 1 }
iter_without_into_iter = { level = "allow", priority = 1 }
large_stack_arrays = { level = "allow", priority = 1 }
linkedlist = { level = "allow", priority = 1 }
manual_assert = { level = "allow", priority = 1 }
manual_let_else = { level = "allow", priority = 1 }
manual_string_new = { level = "allow", priority = 1 }
many_single_char_names = { level = "allow", priority = 1 }
match_wildcard_for_single_variants = { level = "allow", priority = 1 }
missing_errors_doc = { level = "allow", priority = 1 }
missing_fields_in_debug = { level = "allow", priority = 1 }
missing_panics_doc = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 }
must_use_candidate = { level = "allow", priority = 1 }
needless_pass_by_value = { level = "allow", priority = 1 }
redundant_closure_for_method_calls = { level = "allow", priority = 1 }
ref_option = { level = "allow", priority = 1 }
return_self_not_must_use = { level = "allow", priority = 1 }
semicolon_if_nothing_returned = { level = "allow", priority = 1 }
should_panic_without_expect = { level = "allow", priority = 1 }
similar_names = { level = "allow", priority = 1 }
single_match_else = { level = "allow", priority = 1 }
stable_sort_primitive = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
trivially_copy_pass_by_ref = { level = "allow", priority = 1 }
unnecessary_box_returns = { level = "allow", priority = 1 }
unnecessary_semicolon = { level = "allow", priority = 1 }
unnested_or_patterns = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }
unused_self = { level = "allow", priority = 1 }
used_underscore_binding = { level = "allow", priority = 1 }
# restriction-lints:
absolute_paths = { level = "allow", priority = 1 }
allow_attributes = { level = "allow", priority = 1 }
allow_attributes_without_reason = { level = "allow", priority = 1 }
arbitrary_source_item_ordering = { level = "allow", priority = 1 }
arithmetic_side_effects = { level = "allow", priority = 1 }
as_conversions = { level = "allow", priority = 1 }
assertions_on_result_states = { level = "allow", priority = 1 }
blanket_clippy_restriction_lints = { level = "allow", priority = 1 }
cfg_not_test = { level = "allow", priority = 1 }
clone_on_ref_ptr = { level = "allow", priority = 1 }
dbg_macro = { level = "allow", priority = 1 }
decimal_literal_representation = { level = "allow", priority = 1 }
default_numeric_fallback = { level = "allow", priority = 1 }
deref_by_slicing = { level = "allow", priority = 1 }
else_if_without_else = { level = "allow", priority = 1 }
exhaustive_enums = { level = "allow", priority = 1 }
exhaustive_structs = { level = "allow", priority = 1 }
expect_used = { level = "allow", priority = 1 }
field_scoped_visibility_modifiers = { level = "allow", priority = 1 }
float_arithmetic = { level = "allow", priority = 1 }
float_cmp_const = { level = "allow", priority = 1 }
if_then_some_else_none = { level = "allow", priority = 1 }
impl_trait_in_params = { level = "allow", priority = 1 }
implicit_return = { level = "allow", priority = 1 }
indexing_slicing = { level = "allow", priority = 1 }
integer_division = { level = "allow", priority = 1 }
integer_division_remainder_used = { level = "allow", priority = 1 }
iter_over_hash_type = { level = "allow", priority = 1 }
little_endian_bytes = { level = "allow", priority = 1 }
map_err_ignore = { level = "allow", priority = 1 }
map_with_unused_argument_over_ranges = { level = "allow", priority = 1 }
min_ident_chars = { level = "allow", priority = 1 }
missing_assert_message = { level = "allow", priority = 1 }
missing_asserts_for_indexing = { level = "allow", priority = 1 }
missing_docs_in_private_items = { level = "allow", priority = 1 }
missing_inline_in_public_items = { level = "allow", priority = 1 }
missing_trait_methods = { level = "allow", priority = 1 }
mod_module_files = { level = "allow", priority = 1 }
modulo_arithmetic = { level = "allow", priority = 1 }
multiple_unsafe_ops_per_block = { level = "allow", priority = 1 }
non_ascii_literal = { level = "allow", priority = 1 }
panic = { level = "allow", priority = 1 }
partial_pub_fields = { level = "allow", priority = 1 }
pattern_type_mismatch = { level = "allow", priority = 1 }
precedence_bits = { level = "allow", priority = 1 }
print_stderr = { level = "allow", priority = 1 }
print_stdout = { level = "allow", priority = 1 }
pub_use = { level = "allow", priority = 1 }
pub_with_shorthand = { level = "allow", priority = 1 }
question_mark_used = { level = "allow", priority = 1 }
redundant_test_prefix = { level = "allow", priority = 1 }
renamed_function_params = { level = "allow", priority = 1 }
same_name_method = { level = "allow", priority = 1 }
semicolon_outside_block = { level = "allow", priority = 1 }
separated_literal_suffix = { level = "allow", priority = 1 }
shadow_reuse = { level = "allow", priority = 1 }
shadow_same = { level = "allow", priority = 1 }
shadow_unrelated = { level = "allow", priority = 1 }
single_call_fn = { level = "allow", priority = 1 }
single_char_lifetime_names = { level = "allow", priority = 1 }
std_instead_of_alloc = { level = "allow", priority = 1 }
std_instead_of_core = { level = "allow", priority = 1 }
str_to_string = { level = "allow", priority = 1 }
string_add = { level = "allow", priority = 1 }
string_slice = { level = "allow", priority = 1 }
undocumented_unsafe_blocks = { level = "allow", priority = 1 }
unnecessary_safety_comment = { level = "allow", priority = 1 }
unreachable = { level = "allow", priority = 1 }
unseparated_literal_suffix = { level = "allow", priority = 1 }
unused_trait_names = { level = "allow", priority = 1 }
unwrap_in_result = { level = "allow", priority = 1 }
unwrap_used = { level = "allow", priority = 1 }
use_debug = { level = "allow", priority = 1 }
used_underscore_items = { level = "allow", priority = 1 }
wildcard_enum_match_arm = { level = "allow", priority = 1 }
# style-lints:
doc_lazy_continuation = { level = "allow", priority = 1 }
doc_overindented_list_items = { level = "allow", priority = 1 }
doc_paragraphs_missing_punctuation = { level = "allow", priority = 1 }
needless_range_loop = { level = "allow", priority = 1 }
needless_return = { level = "allow", priority = 1 }


================================================
FILE: DIRECTORY.md
================================================
# List of all files

## src
  * Backtracking
    * [All Combinations of Size K](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/all_combination_of_size_k.rs)
    * [Graph Coloring](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/graph_coloring.rs)
    * [Hamiltonian Cycle](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/hamiltonian_cycle.rs)
    * [Knight Tour](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/knight_tour.rs)
    * [N-Queens](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/n_queens.rs)
    * [Parentheses Generator](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/parentheses_generator.rs)
    * [Permutations](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/permutations.rs)
    * [Rat in Maze](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/rat_in_maze.rs)
    * [Subset Sum](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/subset_sum.rs)
    * [Sudoku](https://github.com/TheAlgorithms/Rust/blob/master/src/backtracking/sudoku.rs)
  * Big Integer
    * [Fast Factorial](https://github.com/TheAlgorithms/Rust/blob/master/src/big_integer/fast_factorial.rs)
    * [Multiply](https://github.com/TheAlgorithms/Rust/blob/master/src/big_integer/multiply.rs)
    * [Poly1305](https://github.com/TheAlgorithms/Rust/blob/master/src/big_integer/poly1305.rs)
  * Bit Manipulation
    * [Binary Coded Decimal](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/binary_coded_decimal.rs)
    * [Binary Shifts](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/binary_shifts.rs)
    * [Counting Bits](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/counting_bits.rs)
    * [Hamming Distance](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/hamming_distance.rs)
    * [Highest Set Bit](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/highest_set_bit.rs)
    * [Is Power of Two](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/is_power_of_two.rs)
    * [Missing Number](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/find_missing_number.rs)
    * [N Bits Gray Code](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/n_bits_gray_code.rs)
    * [Previous Power of Two](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/find_previous_power_of_two.rs)
    * [Reverse Bits](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/reverse_bits.rs)
    * [Rightmost Set Bit](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/rightmost_set_bit.rs)
    * [Sum of Two Integers](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/sum_of_two_integers.rs)
    * [Swap Odd and Even Bits](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/swap_odd_even_bits.rs)
    * [Trailing Zeros](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/binary_count_trailing_zeros.rs)
    * [Two's Complement](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/twos_complement.rs)
    * [Unique Number](https://github.com/TheAlgorithms/Rust/blob/master/src/bit_manipulation/find_unique_number.rs)
  * Ciphers
    * [AES](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/aes.rs)
    * [Affine Cipher](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/affine_cipher.rs)
    * [Another ROT13](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/another_rot13.rs)
    * [Baconian Cipher](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/baconian_cipher.rs)
    * [Base16](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/base16.rs)
    * [Base32](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/base32.rs)
    * [Base64](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/base64.rs)
    * [Base85](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/base85.rs)
    * [Blake2B](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/blake2b.rs)
    * [Caesar](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/caesar.rs)
    * [Chacha](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/chacha.rs)
    * [Diffie-Hellman](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/diffie_hellman.rs)
    * [Hashing Traits](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/hashing_traits.rs)
    * [Hill Cipher](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/hill_cipher.rs)
    * [Kernighan](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/kernighan.rs)
    * [Morse Code](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/morse_code.rs)
    * [Polybius](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/polybius.rs)
    * [Rail Fence](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/rail_fence.rs)
    * [ROT13](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/rot13.rs)
    * [RSA Cipher](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/rsa_cipher.rs)
    * [Salsa](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/salsa.rs)
    * [SHA-256](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/sha256.rs)
    * [SHA-3](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/sha3.rs)
    * [Tea](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/tea.rs)
    * [Theoretical ROT13](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/theoretical_rot13.rs)
    * [Transposition](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/transposition.rs)
    * [Trifid](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/trifid.rs)
    * [Vernam](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/vernam.rs)
    * [Vigenere](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/vigenere.rs)
    * [XOR](https://github.com/TheAlgorithms/Rust/blob/master/src/ciphers/xor.rs)
  * Compression
    * [Burrows-Wheeler Transform](https://github.com/TheAlgorithms/Rust/blob/master/src/compression/burrows_wheeler_transform.rs)
    * [Huffman Encoding](https://github.com/TheAlgorithms/Rust/blob/master/src/compression/huffman_encoding.rs)
    * [LZ77](https://github.com/TheAlgorithms/Rust/blob/master/src/compression/lz77.rs)
    * [Move to Front](https://github.com/TheAlgorithms/Rust/blob/master/src/compression/move_to_front.rs)
    * [Run Length Encoding](https://github.com/TheAlgorithms/Rust/blob/master/src/compression/run_length_encoding.rs)
  * Conversions
    * [Binary to Decimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/binary_to_decimal.rs)
    * [Binary to Hexadecimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/binary_to_hexadecimal.rs)
    * [Binary to Octal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/binary_to_octal.rs)
    * [Decimal to Binary](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/decimal_to_binary.rs)
    * [Decimal to Hexadecimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/decimal_to_hexadecimal.rs)
    * [Decimal to Octal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/decimal_to_octal.rs)
    * [Energy](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/energy.rs)
    * [Hexadecimal to Binary](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/hexadecimal_to_binary.rs)
    * [Hexadecimal to Decimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/hexadecimal_to_decimal.rs)
    * [Hexadecimal to Octal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/hexadecimal_to_octal.rs)
    * [IPv4 Conversion](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/ipv4_conversion.rs)
    * [Length Conversion](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/length_conversion.rs)
    * [Octal to Binary](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/octal_to_binary.rs)
    * [Octal to Decimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/octal_to_decimal.rs)
    * [Octal to Hexadecimal](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/octal_to_hexadecimal.rs)
    * [Order of Magnitude Conversion](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/order_of_magnitude_conversion.rs)
    * [Pressure](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/pressure.rs)
    * [Rectangular to Polar](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/rectangular_to_polar.rs)
    * [RGB-CMYK Conversion](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/rgb_cmyk_conversion.rs)
    * [RGB-HSV Conversion](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/rgb_hsv_conversion.rs)
    * [Roman Numerals](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/roman_numerals.rs)
    * [Speed](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/speed.rs)
    * [Time](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/time.rs)
    * [Temperature](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/temperature.rs)
    * [Volume](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/volume.rs)
    * [Weight](https://github.com/TheAlgorithms/Rust/blob/master/src/conversions/weight.rs)
  * Data Structures
    * [AVL Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/avl_tree.rs)
    * [B-Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/b_tree.rs)
    * [Binary Search Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/binary_search_tree.rs)
    * [Fenwick Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/fenwick_tree.rs)
    * [Floyds Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/floyds_algorithm.rs)
    * [Graph](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/graph.rs)
    * [Hash Table](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/hash_table.rs)
    * [Heap](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/heap.rs)
    * [Lazy Segment Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/lazy_segment_tree.rs)
    * [Linked List](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/linked_list.rs)
    * Probabilistic
      * [Bloom Filter](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/probabilistic/bloom_filter.rs)
      * [Count Min Sketch](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/probabilistic/count_min_sketch.rs)
    * [Queue](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/queue.rs)
    * [Range Minimum Query](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/range_minimum_query.rs)
    * [RB Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/rb_tree.rs)
    * [Segment Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/segment_tree.rs)
    * [Segment Tree Recursive](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/segment_tree_recursive.rs)
    * [Stack Using Singly Linked List](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/stack_using_singly_linked_list.rs)
    * [Treap](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/treap.rs)
    * [Trie](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/trie.rs)
    * [Union Find](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/union_find.rs)
    * [Veb Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/data_structures/veb_tree.rs)
  * Dynamic Programming
    * [Catalan Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/catalan_numbers.rs)
    * [Coin Change](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/coin_change.rs)
    * [Egg Dropping](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/egg_dropping.rs)
    * [Fibonacci](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/fibonacci.rs)
    * [Fractional Knapsack](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/fractional_knapsack.rs)
    * [Integer Partition](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/integer_partition.rs)
    * [Is Subsequence](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/is_subsequence.rs)
    * [Knapsack](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/knapsack.rs)
    * [Longest Common Subsequence](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/longest_common_subsequence.rs)
    * [Longest Common Substring](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/longest_common_substring.rs)
    * [Longest Continuous Increasing Subsequence](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/longest_continuous_increasing_subsequence.rs)
    * [Longest Increasing Subsequence](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/longest_increasing_subsequence.rs)
    * [Matrix Chain Multiply](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/matrix_chain_multiply.rs)
    * [Maximal Square](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/maximal_square.rs)
    * [Maximum Subarray](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/maximum_subarray.rs)
    * [Minimum Cost Path](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/minimum_cost_path.rs)
    * [Optimal BST](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/optimal_bst.rs)
    * [Palindrome Partitioning](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/palindrome_partitioning.rs)
    * [Rod Cutting](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/rod_cutting.rs)
    * [Smith-Waterman](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/smith_waterman.rs)
    * [Snail](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/snail.rs)
    * [Subset Generation](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/subset_generation.rs)
    * [Subset Sum](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/subset_sum.rs)
    * [Task Assignment](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/task_assignment.rs)
    * [Trapped Rainwater](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/trapped_rainwater.rs)
    * [Word Break](https://github.com/TheAlgorithms/Rust/blob/master/src/dynamic_programming/word_break.rs)
  * Financial
    * [Depreciation](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/depreciation.rs)
    * [Equated Monthly Installments](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/equated_monthly_installments.rs)
    * [Exponential Moving Average](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/exponential_moving_average.rs)
    * [Finance Ratios](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/finance_ratios.rs)
    * [Interest](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/interest.rs)
    * [Net Present Value](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/npv.rs)
    * [NPV Sensitivity](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/npv_sensitivity.rs)
    * [Payback Period](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/payback.rs)
    * [Present Value](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/present_value.rs)
    * [Treynor Ratio](https://github.com/TheAlgorithms/Rust/blob/master/src/financial/treynor_ratio.rs)
  * General
    * [Convex Hull](https://github.com/TheAlgorithms/Rust/blob/master/src/general/convex_hull.rs)
    * [Fisher Yates Shuffle](https://github.com/TheAlgorithms/Rust/blob/master/src/general/fisher_yates_shuffle.rs)
    * [Genetic](https://github.com/TheAlgorithms/Rust/blob/master/src/general/genetic.rs)
    * [Hanoi](https://github.com/TheAlgorithms/Rust/blob/master/src/general/hanoi.rs)
    * [Huffman Encoding](https://github.com/TheAlgorithms/Rust/blob/master/src/general/huffman_encoding.rs)
    * [Kadane Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/general/kadane_algorithm.rs)
    * [K-Means](https://github.com/TheAlgorithms/Rust/blob/master/src/general/kmeans.rs)
    * [Mex](https://github.com/TheAlgorithms/Rust/blob/master/src/general/mex.rs)
    * Permutations
      * [Heap](https://github.com/TheAlgorithms/Rust/blob/master/src/general/permutations/heap.rs)
      * [Naive](https://github.com/TheAlgorithms/Rust/blob/master/src/general/permutations/naive.rs)
      * [Steinhaus Johnson Trotter](https://github.com/TheAlgorithms/Rust/blob/master/src/general/permutations/steinhaus_johnson_trotter.rs)
    * [Subarray Sum Equals K](https://github.com/TheAlgorithms/Rust/blob/master/src/general/subarray_sum_equals_k.rs)
    * [Two Sum](https://github.com/TheAlgorithms/Rust/blob/master/src/general/two_sum.rs)
  * Geometry
    * [Closest Points](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/closest_points.rs)
    * [Graham Scan](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/graham_scan.rs)
    * [Jarvis Scan](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/jarvis_scan.rs)
    * [Point](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/point.rs)
    * [Polygon Points](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/polygon_points.rs)
    * [Ramer Douglas Peucker](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/ramer_douglas_peucker.rs)
    * [Segment](https://github.com/TheAlgorithms/Rust/blob/master/src/geometry/segment.rs)
  * Graph
    * [A*](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/astar.rs)
    * [Ant Colony Optimization](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/ant_colony_optimization.rs)
    * [Bellman-Ford](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/bellman_ford.rs)
    * [Bipartite Matching](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/bipartite_matching.rs)
    * [Breadth First Search](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/breadth_first_search.rs)
    * [Centroid Decomposition](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/centroid_decomposition.rs)
    * [Decremental Connectivity](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/decremental_connectivity.rs)
    * [Depth First Search](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/depth_first_search.rs)
    * [Depth First Search Tic-Tac-Toe](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/depth_first_search_tic_tac_toe.rs)
    * [Detect Cycle](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/detect_cycle.rs)
    * [Dijkstra](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/dijkstra.rs)
    * [Dinic Maxflow](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/dinic_maxflow.rs)
    * [Disjoint Set Union](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/disjoint_set_union.rs)
    * [Eulerian Path](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/eulerian_path.rs)
    * [Floyd Warshall](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/floyd_warshall.rs)
    * [Ford Fulkerson](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/ford_fulkerson.rs)
    * [Graph Enumeration](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/graph_enumeration.rs)
    * [Heavy Light Decomposition](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/heavy_light_decomposition.rs)
    * [Kosaraju](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/kosaraju.rs)
    * [Lee Breadth First Search](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/lee_breadth_first_search.rs)
    * [Lowest Common Ancestor](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/lowest_common_ancestor.rs)
    * [Minimum Spanning Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/minimum_spanning_tree.rs)
    * [Prim](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/prim.rs)
    * [Prufer Code](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/prufer_code.rs)
    * [Strongly Connected Components](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/strongly_connected_components.rs)
    * [Tarjans Strongly Connected Components](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/tarjans_ssc.rs)
    * [Topological Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/topological_sort.rs)
    * [Two Satisfiability](https://github.com/TheAlgorithms/Rust/blob/master/src/graph/two_satisfiability.rs)
  * Greedy
    * [Minimum Coin Change](https://github.com/TheAlgorithms/Rust/blob/master/src/greedy/minimum_coin_changes.rs)
    * [Smallest Range](https://github.com/TheAlgorithms/Rust/blob/master/src/greedy/smallest_range.rs)
    * [Stable Matching](https://github.com/TheAlgorithms/Rust/blob/master/src/greedy/stable_matching.rs)
  * [Lib](https://github.com/TheAlgorithms/Rust/blob/master/src/lib.rs)
  * Machine Learning
    * [Cholesky](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/cholesky.rs)
    * [Decision Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/decision_tree.rs)
    * [K-Means](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/k_means.rs)
    * [K-Nearest Neighbors](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/k_nearest_neighbors.rs)
    * [Linear Regression](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/linear_regression.rs)
    * [Logistic Regression](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/logistic_regression.rs)
    * [Naive Bayes](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/naive_bayes.rs)
    * [Perceptron](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/perceptron.rs)
    * [Principal Component Analysis](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/principal_component_analysis.rs)
    * [Random Forest](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/random_forest.rs)
    * [Support Vector Classifier](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/support_vector_classifier.rs)
    * Loss Function
      * [Average Margin Ranking Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/average_margin_ranking_loss.rs)
      * [Hinge Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/hinge_loss.rs)
      * [Huber Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/huber_loss.rs)
      * [KL Divergence Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/kl_divergence_loss.rs)
      * [Mean Absolute Error Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/mean_absolute_error_loss.rs)
      * [Mean Squared Error Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/mean_squared_error_loss.rs)
      * [Negative Log Likelihood](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/loss_function/negative_log_likelihood.rs)
    * Optimization
      * [Adam](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/optimization/adam.rs)
      * [Gradient Descent](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/optimization/gradient_descent.rs)
      * [Momentum](https://github.com/TheAlgorithms/Rust/blob/master/src/machine_learning/optimization/momentum.rs)
  * Math
    * [Absolute](https://github.com/TheAlgorithms/Rust/blob/master/src/math/abs.rs)
    * [Aliquot Sum](https://github.com/TheAlgorithms/Rust/blob/master/src/math/aliquot_sum.rs)
    * [Amicable Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/amicable_numbers.rs)
    * [Area of Polygon](https://github.com/TheAlgorithms/Rust/blob/master/src/math/area_of_polygon.rs)
    * [Area Under Curve](https://github.com/TheAlgorithms/Rust/blob/master/src/math/area_under_curve.rs)
    * [Armstrong Number](https://github.com/TheAlgorithms/Rust/blob/master/src/math/armstrong_number.rs)
    * [Average](https://github.com/TheAlgorithms/Rust/blob/master/src/math/average.rs)
    * [Baby Step Giant Step](https://github.com/TheAlgorithms/Rust/blob/master/src/math/baby_step_giant_step.rs)
    * [Bell Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/bell_numbers.rs)
    * [Binary Exponentiation](https://github.com/TheAlgorithms/Rust/blob/master/src/math/binary_exponentiation.rs)
    * [Binomial Coefficient](https://github.com/TheAlgorithms/Rust/blob/master/src/math/binomial_coefficient.rs)
    * [Catalan Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/catalan_numbers.rs)
    * [Ceil](https://github.com/TheAlgorithms/Rust/blob/master/src/math/ceil.rs)
    * [Chinese Remainder Theorem](https://github.com/TheAlgorithms/Rust/blob/master/src/math/chinese_remainder_theorem.rs)
    * [Collatz Sequence](https://github.com/TheAlgorithms/Rust/blob/master/src/math/collatz_sequence.rs)
    * [Combinations](https://github.com/TheAlgorithms/Rust/blob/master/src/math/combinations.rs)
    * [Cross Entropy Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/math/cross_entropy_loss.rs)
    * [Decimal to Fraction](https://github.com/TheAlgorithms/Rust/blob/master/src/math/decimal_to_fraction.rs)
    * [Doomsday](https://github.com/TheAlgorithms/Rust/blob/master/src/math/doomsday.rs)
    * [Elliptic Curve](https://github.com/TheAlgorithms/Rust/blob/master/src/math/elliptic_curve.rs)
    * [Euclidean Distance](https://github.com/TheAlgorithms/Rust/blob/master/src/math/euclidean_distance.rs)
    * [Exponential Linear Unit](https://github.com/TheAlgorithms/Rust/blob/master/src/math/exponential_linear_unit.rs)
    * [Extended Euclidean Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/math/extended_euclidean_algorithm.rs)
    * [Factorial](https://github.com/TheAlgorithms/Rust/blob/master/src/math/factorial.rs)
    * [Factors](https://github.com/TheAlgorithms/Rust/blob/master/src/math/factors.rs)
    * [Fast Fourier Transform](https://github.com/TheAlgorithms/Rust/blob/master/src/math/fast_fourier_transform.rs)
    * [Fast Power](https://github.com/TheAlgorithms/Rust/blob/master/src/math/fast_power.rs)
    * [Faster Perfect Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/faster_perfect_numbers.rs)
    * [Field](https://github.com/TheAlgorithms/Rust/blob/master/src/math/field.rs)
    * [Frizzy Number](https://github.com/TheAlgorithms/Rust/blob/master/src/math/frizzy_number.rs)
    * [Gaussian Elimination](https://github.com/TheAlgorithms/Rust/blob/master/src/math/gaussian_elimination.rs)
    * [Gaussian Error Linear Unit](https://github.com/TheAlgorithms/Rust/blob/master/src/math/gaussian_error_linear_unit.rs)
    * [GCD of N Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/gcd_of_n_numbers.rs)
    * [Geometric Series](https://github.com/TheAlgorithms/Rust/blob/master/src/math/geometric_series.rs)
    * [Greatest Common Divisor](https://github.com/TheAlgorithms/Rust/blob/master/src/math/greatest_common_divisor.rs)
    * [Huber Loss](https://github.com/TheAlgorithms/Rust/blob/master/src/math/huber_loss.rs)
    * [Infix to Postfix](https://github.com/TheAlgorithms/Rust/blob/master/src/math/infix_to_postfix.rs)
    * [Interest](https://github.com/TheAlgorithms/Rust/blob/master/src/math/interest.rs)
    * [Interpolation](https://github.com/TheAlgorithms/Rust/blob/master/src/math/interpolation.rs)
    * [Interquartile Range](https://github.com/TheAlgorithms/Rust/blob/master/src/math/interquartile_range.rs)
    * [Karatsuba Multiplication](https://github.com/TheAlgorithms/Rust/blob/master/src/math/karatsuba_multiplication.rs)
    * [LCM of N Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/lcm_of_n_numbers.rs)
    * [Leaky Relu](https://github.com/TheAlgorithms/Rust/blob/master/src/math/leaky_relu.rs)
    * [Least Square Approx](https://github.com/TheAlgorithms/Rust/blob/master/src/math/least_square_approx.rs)
    * [Linear Sieve](https://github.com/TheAlgorithms/Rust/blob/master/src/math/linear_sieve.rs)
    * [Logarithm](https://github.com/TheAlgorithms/Rust/blob/master/src/math/logarithm.rs)
    * [Lucas Series](https://github.com/TheAlgorithms/Rust/blob/master/src/math/lucas_series.rs)
    * [Matrix Ops](https://github.com/TheAlgorithms/Rust/blob/master/src/math/matrix_ops.rs)
    * [Mersenne Primes](https://github.com/TheAlgorithms/Rust/blob/master/src/math/mersenne_primes.rs)
    * [Miller Rabin](https://github.com/TheAlgorithms/Rust/blob/master/src/math/miller_rabin.rs)
    * [Modular Exponential](https://github.com/TheAlgorithms/Rust/blob/master/src/math/modular_exponential.rs)
    * [Newton Raphson](https://github.com/TheAlgorithms/Rust/blob/master/src/math/newton_raphson.rs)
    * [N-th prime](https://github.com/TheAlgorithms/Rust/blob/master/src/math/nthprime.rs)
    * [Pascal Triangle](https://github.com/TheAlgorithms/Rust/blob/master/src/math/pascal_triangle.rs)
    * [Perfect Cube](https://github.com/TheAlgorithms/Rust/blob/master/src/math/perfect_cube.rs)
    * [Perfect Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/perfect_numbers.rs)
    * [Perfect Square](https://github.com/TheAlgorithms/Rust/blob/master/src/math/perfect_square.rs)
    * [Pollard Rho](https://github.com/TheAlgorithms/Rust/blob/master/src/math/pollard_rho.rs)
    * [Postfix Evaluation](https://github.com/TheAlgorithms/Rust/blob/master/src/math/postfix_evaluation.rs)
    * [Prime Check](https://github.com/TheAlgorithms/Rust/blob/master/src/math/prime_check.rs)
    * [Prime Factors](https://github.com/TheAlgorithms/Rust/blob/master/src/math/prime_factors.rs)
    * [Prime Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/prime_numbers.rs)
    * [Quadratic Residue](https://github.com/TheAlgorithms/Rust/blob/master/src/math/quadratic_residue.rs)
    * [Random](https://github.com/TheAlgorithms/Rust/blob/master/src/math/random.rs)
    * [ReLU](https://github.com/TheAlgorithms/Rust/blob/master/src/math/relu.rs)
    * [Sieve of Eratosthenes](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sieve_of_eratosthenes.rs)
    * [Sigmoid](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sigmoid.rs)
    * [Signum](https://github.com/TheAlgorithms/Rust/blob/master/src/math/signum.rs)
    * [Simpsons Integration](https://github.com/TheAlgorithms/Rust/blob/master/src/math/simpsons_integration.rs)
    * [Softmax](https://github.com/TheAlgorithms/Rust/blob/master/src/math/softmax.rs)
    * [Sprague Grundy Theorem](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sprague_grundy_theorem.rs)
    * [Square Pyramidal Numbers](https://github.com/TheAlgorithms/Rust/blob/master/src/math/square_pyramidal_numbers.rs)
    * [Square Root](https://github.com/TheAlgorithms/Rust/blob/master/src/math/square_root.rs)
    * [Sum of Digits](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sum_of_digits.rs)
    * [Sum of Geometric Progression](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sum_of_geometric_progression.rs)
    * [Sum of Harmonic Series](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sum_of_harmonic_series.rs)
    * [Sylvester Sequence](https://github.com/TheAlgorithms/Rust/blob/master/src/math/sylvester_sequence.rs)
    * [Tanh](https://github.com/TheAlgorithms/Rust/blob/master/src/math/tanh.rs)
    * [Trapezoidal Integration](https://github.com/TheAlgorithms/Rust/blob/master/src/math/trapezoidal_integration.rs)
    * [Trial Division](https://github.com/TheAlgorithms/Rust/blob/master/src/math/trial_division.rs)
    * [Trig Functions](https://github.com/TheAlgorithms/Rust/blob/master/src/math/trig_functions.rs)
    * [Vector Cross Product](https://github.com/TheAlgorithms/Rust/blob/master/src/math/vector_cross_product.rs)
    * [Zellers Congruence Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/math/zellers_congruence_algorithm.rs)
  * Navigation
    * [Bearing](https://github.com/TheAlgorithms/Rust/blob/master/src/navigation/bearing.rs)
    * [Haversine](https://github.com/TheAlgorithms/Rust/blob/master/src/navigation/haversine.rs)
    * [Rhumbline](https://github.com/TheAlgorithms/Rust/blob/master/src/navigation/rhumbline.rs)
  * Number Theory
    * [Compute Totient](https://github.com/TheAlgorithms/Rust/blob/master/src/number_theory/compute_totient.rs)
    * [Euler Totient](https://github.com/TheAlgorithms/Rust/blob/master/src/number_theory/euler_totient.rs)
    * [K-th Factor](https://github.com/TheAlgorithms/Rust/blob/master/src/number_theory/kth_factor.rs)
  * Searching
    * [Binary Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/binary_search.rs)
    * [Binary Search Recursive](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/binary_search_recursive.rs)
    * [Exponential Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/exponential_search.rs)
    * [Fibonacci Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/fibonacci_search.rs)
    * [Interpolation Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/interpolation_search.rs)
    * [Jump Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/jump_search.rs)
    * [K-th Smallest](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/kth_smallest.rs)
    * [K-th Smallest Heap](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/kth_smallest_heap.rs)
    * [Linear Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/linear_search.rs)
    * [Moore Voting](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/moore_voting.rs)
    * [Quick Select](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/quick_select.rs)
    * [Saddleback Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/saddleback_search.rs)
    * [Ternary Search](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/ternary_search.rs)
    * [Ternary Search Min Max](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/ternary_search_min_max.rs)
    * [Ternary Search Min Max Recursive](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/ternary_search_min_max_recursive.rs)
    * [Ternary Search Recursive](https://github.com/TheAlgorithms/Rust/blob/master/src/searching/ternary_search_recursive.rs)
  * Signal Analysis
    * [YIN](https://github.com/TheAlgorithms/Rust/blob/master/src/signal_analysis/yin.rs)
  * Sorting
    * [Bead Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bead_sort.rs)
    * [Binary Insertion Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/binary_insertion_sort.rs)
    * [Bingo Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bingo_sort.rs)
    * [Bitonic Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bitonic_sort.rs)
    * [Bogo Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bogo_sort.rs)
    * [Bubble Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bubble_sort.rs)
    * [Bucket Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/bucket_sort.rs)
    * [Cocktail Shaker Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/cocktail_shaker_sort.rs)
    * [Comb Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/comb_sort.rs)
    * [Counting Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/counting_sort.rs)
    * [Cycle Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/cycle_sort.rs)
    * [Dutch National Flag Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/dutch_national_flag_sort.rs)
    * [Exchange Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/exchange_sort.rs)
    * [Gnome Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/gnome_sort.rs)
    * [Heap Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/heap_sort.rs)
    * [Insertion Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/insertion_sort.rs)
    * [Intro Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/intro_sort.rs)
    * [Merge Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/merge_sort.rs)
    * [Odd Even Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/odd_even_sort.rs)
    * [Pancake Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/pancake_sort.rs)
    * [Patience Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/patience_sort.rs)
    * [Pigeonhole Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/pigeonhole_sort.rs)
    * [Quick Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/quick_sort.rs)
    * [Quick Sort 3-ways](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/quick_sort_3_ways.rs)
    * [Radix Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/radix_sort.rs)
    * [Selection Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/selection_sort.rs)
    * [Shell Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/shell_sort.rs)
    * [Sleep Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/sleep_sort.rs)
    * [Sort Utils](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/sort_utils.rs)
    * [Stooge Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/stooge_sort.rs)
    * [Tim Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/tim_sort.rs)
    * [Tree Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/tree_sort.rs)
    * [Wave Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/wave_sort.rs)
    * [Wiggle Sort](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/wiggle_sort.rs)
  * String
    * [Aho Corasick](https://github.com/TheAlgorithms/Rust/blob/master/src/string/aho_corasick.rs)
    * [Anagram](https://github.com/TheAlgorithms/Rust/blob/master/src/string/anagram.rs)
    * [Autocomplete Using Trie](https://github.com/TheAlgorithms/Rust/blob/master/src/string/autocomplete_using_trie.rs)
    * [Boyer Moore Search](https://github.com/TheAlgorithms/Rust/blob/master/src/string/boyer_moore_search.rs)
    * [Burrows Wheeler Transform](https://github.com/TheAlgorithms/Rust/blob/master/src/string/burrows_wheeler_transform.rs)
    * [Duval Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/string/duval_algorithm.rs)
    * [Hamming Distance](https://github.com/TheAlgorithms/Rust/blob/master/src/string/hamming_distance.rs)
    * [Isogram](https://github.com/TheAlgorithms/Rust/blob/master/src/string/isogram.rs)
    * [Isomorphism](https://github.com/TheAlgorithms/Rust/blob/master/src/string/isomorphism.rs)
    * [Jaro Winkler Distance](https://github.com/TheAlgorithms/Rust/blob/master/src/string/jaro_winkler_distance.rs)
    * [Knuth Morris Pratt](https://github.com/TheAlgorithms/Rust/blob/master/src/string/knuth_morris_pratt.rs)
    * [Levenshtein Distance](https://github.com/TheAlgorithms/Rust/blob/master/src/string/levenshtein_distance.rs)
    * [Lipogram](https://github.com/TheAlgorithms/Rust/blob/master/src/string/lipogram.rs)
    * [Manacher](https://github.com/TheAlgorithms/Rust/blob/master/src/string/manacher.rs)
    * [Palindrome](https://github.com/TheAlgorithms/Rust/blob/master/src/string/palindrome.rs)
    * [Pangram](https://github.com/TheAlgorithms/Rust/blob/master/src/string/pangram.rs)
    * [Rabin Karp](https://github.com/TheAlgorithms/Rust/blob/master/src/string/rabin_karp.rs)
    * [Reverse](https://github.com/TheAlgorithms/Rust/blob/master/src/string/reverse.rs)
    * [Run Length Encoding](https://github.com/TheAlgorithms/Rust/blob/master/src/string/run_length_encoding.rs)
    * [Shortest Palindrome](https://github.com/TheAlgorithms/Rust/blob/master/src/string/shortest_palindrome.rs)
    * [Suffix Array](https://github.com/TheAlgorithms/Rust/blob/master/src/string/suffix_array.rs)
    * [Suffix Array Manber Myers](https://github.com/TheAlgorithms/Rust/blob/master/src/string/suffix_array_manber_myers.rs)
    * [Suffix Tree](https://github.com/TheAlgorithms/Rust/blob/master/src/string/suffix_tree.rs)
    * [Z Algorithm](https://github.com/TheAlgorithms/Rust/blob/master/src/string/z_algorithm.rs)


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2019 The Algorithms

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
<div align="center">
<!-- Title: -->
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Rust_programming_language_black_logo.svg/1024px-Rust_programming_language_black_logo.svg.png" width="100" height="100">

<h1><a href="https://github.com/TheAlgorithms/">The Algorithms</a> - Rust</h1>

<!-- Labels: -->
<a href="https://gitpod.io/#https://github.com/TheAlgorithms/Rust">
    <img src="https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square" height="20" alt="Gitpod Ready-to-Code">
</a>
<a href="https://github.com/TheAlgorithms/Rust/actions/workflows/build.yml">
  <img src="https://github.com/TheAlgorithms/Rust/actions/workflows/build.yml/badge.svg" height="20" alt="Build workflow">
</a>
<a href="https://codecov.io/gh/TheAlgorithms/Rust" > 
  <img src="https://codecov.io/gh/TheAlgorithms/Rust/graph/badge.svg?token=nRkPKfbs42"/> 
</a>
<a href="https://the-algorithms.com/discord">
  <img src="https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=00d37d" height="20" alt="Discord community">
</a>
<a href="https://matrix.to/#/#TheAlgorithms_community:gitter.im">
  <img src="https://img.shields.io/gitter/room/TheAlgorithms/community.svg?style=flat-square" height="20" alt="Gitter chat">
</a>

<!-- Short description: -->
  <h3>All algorithms implemented in Rust - for education</h3>
</div>

### List of Algorithms
See our [directory](DIRECTORY.md) for easier navigation and a better overview of the project.

### Contributing
Read through our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.


================================================
FILE: clippy.toml
================================================
allowed-duplicate-crates = [
    "glam",
]


================================================
FILE: git_hooks/pre-commit
================================================
cargo fmt
cargo test


================================================
FILE: src/backtracking/all_combination_of_size_k.rs
================================================
//! This module provides a function to generate all possible combinations
//! of `k` numbers out of `0...n-1` using a backtracking algorithm.

/// Custom error type for combination generation.
#[derive(Debug, PartialEq)]
pub enum CombinationError {
    KGreaterThanN,
    InvalidZeroRange,
}

/// Generates all possible combinations of `k` numbers out of `0...n-1`.
///
/// # Arguments
///
/// * `n` - The upper limit of the range (`0` to `n-1`).
/// * `k` - The number of elements in each combination.
///
/// # Returns
///
/// A `Result` containing a vector with all possible combinations of `k` numbers out of `0...n-1`,
/// or a `CombinationError` if the input is invalid.
pub fn generate_all_combinations(n: usize, k: usize) -> Result<Vec<Vec<usize>>, CombinationError> {
    if n == 0 && k > 0 {
        return Err(CombinationError::InvalidZeroRange);
    }

    if k > n {
        return Err(CombinationError::KGreaterThanN);
    }

    let mut combinations = vec![];
    let mut current = vec![0; k];
    backtrack(0, n, k, 0, &mut current, &mut combinations);
    Ok(combinations)
}

/// Helper function to generate combinations recursively.
///
/// # Arguments
///
/// * `start` - The current number to start the combination with.
/// * `n` - The upper limit of the range (`0` to `n-1`).
/// * `k` - The number of elements left to complete the combination.
/// * `index` - The current index being filled in the combination.
/// * `current` - A mutable reference to the current combination being constructed.
/// * `combinations` - A mutable reference to the vector holding all combinations.
fn backtrack(
    start: usize,
    n: usize,
    k: usize,
    index: usize,
    current: &mut Vec<usize>,
    combinations: &mut Vec<Vec<usize>>,
) {
    if index == k {
        combinations.push(current.clone());
        return;
    }

    for num in start..=(n - k + index) {
        current[index] = num;
        backtrack(num + 1, n, k, index + 1, current, combinations);
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! combination_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (n, k, expected) = $test_case;
                    assert_eq!(generate_all_combinations(n, k), expected);
                }
            )*
        }
    }

    combination_tests! {
        test_generate_4_2: (4, 2, Ok(vec![
            vec![0, 1],
            vec![0, 2],
            vec![0, 3],
            vec![1, 2],
            vec![1, 3],
            vec![2, 3],
        ])),
        test_generate_4_3: (4, 3, Ok(vec![
            vec![0, 1, 2],
            vec![0, 1, 3],
            vec![0, 2, 3],
            vec![1, 2, 3],
        ])),
        test_generate_5_3: (5, 3, Ok(vec![
            vec![0, 1, 2],
            vec![0, 1, 3],
            vec![0, 1, 4],
            vec![0, 2, 3],
            vec![0, 2, 4],
            vec![0, 3, 4],
            vec![1, 2, 3],
            vec![1, 2, 4],
            vec![1, 3, 4],
            vec![2, 3, 4],
        ])),
        test_generate_5_1: (5, 1, Ok(vec![
            vec![0],
            vec![1],
            vec![2],
            vec![3],
            vec![4],
        ])),
        test_empty: (0, 0, Ok(vec![vec![]])),
        test_generate_n_eq_k: (3, 3, Ok(vec![
            vec![0, 1, 2],
        ])),
        test_generate_k_greater_than_n: (3, 4, Err(CombinationError::KGreaterThanN)),
        test_zero_range_with_nonzero_k: (0, 1, Err(CombinationError::InvalidZeroRange)),
    }
}


================================================
FILE: src/backtracking/graph_coloring.rs
================================================
//! This module provides functionality for generating all possible colorings of a undirected (or directed) graph
//! given a certain number of colors. It includes the GraphColoring struct and methods
//! for validating color assignments and finding all valid colorings.

/// Represents potential errors when coloring on an adjacency matrix.
#[derive(Debug, PartialEq, Eq)]
pub enum GraphColoringError {
    // Indicates that the adjacency matrix is empty
    EmptyAdjacencyMatrix,
    // Indicates that the adjacency matrix is not squared
    ImproperAdjacencyMatrix,
}

/// Generates all possible valid colorings of a graph.
///
/// # Arguments
///
/// * `adjacency_matrix` - A 2D vector representing the adjacency matrix of the graph.
/// * `num_colors` - The number of colors available for coloring the graph.
///
/// # Returns
///
/// * A `Result` containing an `Option` with a vector of solutions or a `GraphColoringError` if
/// there is an issue with the matrix.
pub fn generate_colorings(
    adjacency_matrix: Vec<Vec<bool>>,
    num_colors: usize,
) -> Result<Option<Vec<Vec<usize>>>, GraphColoringError> {
    Ok(GraphColoring::new(adjacency_matrix)?.find_solutions(num_colors))
}

/// A struct representing a graph coloring problem.
struct GraphColoring {
    // The adjacency matrix of the graph
    adjacency_matrix: Vec<Vec<bool>>,
    // The current colors assigned to each vertex
    vertex_colors: Vec<usize>,
    // Vector of all valid color assignments for the vertices found during the search
    solutions: Vec<Vec<usize>>,
}

impl GraphColoring {
    /// Creates a new GraphColoring instance.
    ///
    /// # Arguments
    ///
    /// * `adjacency_matrix` - A 2D vector representing the adjacency matrix of the graph.
    ///
    /// # Returns
    ///
    /// * A new instance of GraphColoring or a `GraphColoringError` if the matrix is empty or non-square.
    fn new(adjacency_matrix: Vec<Vec<bool>>) -> Result<Self, GraphColoringError> {
        let num_vertices = adjacency_matrix.len();

        // Check if the adjacency matrix is empty
        if num_vertices == 0 {
            return Err(GraphColoringError::EmptyAdjacencyMatrix);
        }

        // Check if the adjacency matrix is square
        if adjacency_matrix.iter().any(|row| row.len() != num_vertices) {
            return Err(GraphColoringError::ImproperAdjacencyMatrix);
        }

        Ok(GraphColoring {
            adjacency_matrix,
            vertex_colors: vec![usize::MAX; num_vertices],
            solutions: Vec::new(),
        })
    }

    /// Returns the number of vertices in the graph.
    fn num_vertices(&self) -> usize {
        self.adjacency_matrix.len()
    }

    /// Checks if a given color can be assigned to a vertex without causing a conflict.
    ///
    /// # Arguments
    ///
    /// * `vertex` - The index of the vertex to be colored.
    /// * `color` - The color to be assigned to the vertex.
    ///
    /// # Returns
    ///
    /// * `true` if the color can be assigned to the vertex, `false` otherwise.
    fn is_color_valid(&self, vertex: usize, color: usize) -> bool {
        for neighbor in 0..self.num_vertices() {
            // Check outgoing edges from vertex and incoming edges to vertex
            if (self.adjacency_matrix[vertex][neighbor] || self.adjacency_matrix[neighbor][vertex])
                && self.vertex_colors[neighbor] == color
            {
                return false;
            }
        }
        true
    }

    /// Recursively finds all valid colorings for the graph.
    ///
    /// # Arguments
    ///
    /// * `vertex` - The current vertex to be colored.
    /// * `num_colors` - The number of colors available for coloring the graph.
    fn find_colorings(&mut self, vertex: usize, num_colors: usize) {
        if vertex == self.num_vertices() {
            self.solutions.push(self.vertex_colors.clone());
            return;
        }

        for color in 0..num_colors {
            if self.is_color_valid(vertex, color) {
                self.vertex_colors[vertex] = color;
                self.find_colorings(vertex + 1, num_colors);
                self.vertex_colors[vertex] = usize::MAX;
            }
        }
    }

    /// Finds all solutions for the graph coloring problem.
    ///
    /// # Arguments
    ///
    /// * `num_colors` - The number of colors available for coloring the graph.
    ///
    /// # Returns
    ///
    /// * A `Result` containing an `Option` with a vector of solutions or a `GraphColoringError`.
    fn find_solutions(&mut self, num_colors: usize) -> Option<Vec<Vec<usize>>> {
        self.find_colorings(0, num_colors);
        if self.solutions.is_empty() {
            None
        } else {
            Some(std::mem::take(&mut self.solutions))
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_graph_coloring {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (adjacency_matrix, num_colors, expected) = $test_case;
                    let actual = generate_colorings(adjacency_matrix, num_colors);
                    assert_eq!(actual, expected);
                }
            )*
        };
    }

    test_graph_coloring! {
        test_complete_graph_with_3_colors: (
            vec![
                vec![false, true, true, true],
                vec![true, false, true, false],
                vec![true, true, false, true],
                vec![true, false, true, false],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1, 2, 1],
                vec![0, 2, 1, 2],
                vec![1, 0, 2, 0],
                vec![1, 2, 0, 2],
                vec![2, 0, 1, 0],
                vec![2, 1, 0, 1],
            ]))
        ),
        test_linear_graph_with_2_colors: (
            vec![
                vec![false, true, false, false],
                vec![true, false, true, false],
                vec![false, true, false, true],
                vec![false, false, true, false],
            ],
            2,
            Ok(Some(vec![
                vec![0, 1, 0, 1],
                vec![1, 0, 1, 0],
            ]))
        ),
        test_incomplete_graph_with_insufficient_colors: (
            vec![
                vec![false, true, true],
                vec![true, false, true],
                vec![true, true, false],
            ],
            1,
            Ok(None::<Vec<Vec<usize>>>)
        ),
        test_empty_graph: (
            vec![],
            1,
            Err(GraphColoringError::EmptyAdjacencyMatrix)
        ),
        test_non_square_matrix: (
            vec![
                vec![false, true, true],
                vec![true, false, true],
            ],
            3,
            Err(GraphColoringError::ImproperAdjacencyMatrix)
        ),
        test_single_vertex_graph: (
            vec![
                vec![false],
            ],
            1,
            Ok(Some(vec![
                vec![0],
            ]))
        ),
        test_bipartite_graph_with_2_colors: (
            vec![
                vec![false, true, false, true],
                vec![true, false, true, false],
                vec![false, true, false, true],
                vec![true, false, true, false],
            ],
            2,
            Ok(Some(vec![
                vec![0, 1, 0, 1],
                vec![1, 0, 1, 0],
            ]))
        ),
        test_large_graph_with_3_colors: (
            vec![
                vec![false, true, true, false, true, true, false, true, true, false],
                vec![true, false, true, true, false, true, true, false, true, true],
                vec![true, true, false, true, true, false, true, true, false, true],
                vec![false, true, true, false, true, true, false, true, true, false],
                vec![true, false, true, true, false, true, true, false, true, true],
                vec![true, true, false, true, true, false, true, true, false, true],
                vec![false, true, true, false, true, true, false, true, true, false],
                vec![true, false, true, true, false, true, true, false, true, true],
                vec![true, true, false, true, true, false, true, true, false, true],
                vec![false, true, true, false, true, true, false, true, true, false],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1, 2, 0, 1, 2, 0, 1, 2, 0],
                vec![0, 2, 1, 0, 2, 1, 0, 2, 1, 0],
                vec![1, 0, 2, 1, 0, 2, 1, 0, 2, 1],
                vec![1, 2, 0, 1, 2, 0, 1, 2, 0, 1],
                vec![2, 0, 1, 2, 0, 1, 2, 0, 1, 2],
                vec![2, 1, 0, 2, 1, 0, 2, 1, 0, 2],
            ]))
        ),
        test_disconnected_graph: (
            vec![
                vec![false, false, false],
                vec![false, false, false],
                vec![false, false, false],
            ],
            2,
            Ok(Some(vec![
                vec![0, 0, 0],
                vec![0, 0, 1],
                vec![0, 1, 0],
                vec![0, 1, 1],
                vec![1, 0, 0],
                vec![1, 0, 1],
                vec![1, 1, 0],
                vec![1, 1, 1],
            ]))
        ),
        test_no_valid_coloring: (
            vec![
                vec![false, true, true],
                vec![true, false, true],
                vec![true, true, false],
            ],
            2,
            Ok(None::<Vec<Vec<usize>>>)
        ),
        test_more_colors_than_nodes: (
            vec![
                vec![true, true],
                vec![true, true],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1],
                vec![0, 2],
                vec![1, 0],
                vec![1, 2],
                vec![2, 0],
                vec![2, 1],
            ]))
        ),
        test_no_coloring_with_zero_colors: (
            vec![
                vec![true],
            ],
            0,
            Ok(None::<Vec<Vec<usize>>>)
        ),
        test_complete_graph_with_3_vertices_and_3_colors: (
            vec![
                vec![false, true, true],
                vec![true, false, true],
                vec![true, true, false],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1, 2],
                vec![0, 2, 1],
                vec![1, 0, 2],
                vec![1, 2, 0],
                vec![2, 0, 1],
                vec![2, 1, 0],
            ]))
        ),
        test_directed_graph_with_3_colors: (
            vec![
                vec![false, true, false, true],
                vec![false, false, true, false],
                vec![true, false, false, true],
                vec![true, false, false, false],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1, 2, 1],
                vec![0, 2, 1, 2],
                vec![1, 0, 2, 0],
                vec![1, 2, 0, 2],
                vec![2, 0, 1, 0],
                vec![2, 1, 0, 1],
            ]))
        ),
        test_directed_graph_no_valid_coloring: (
            vec![
                vec![false, true, false, true],
                vec![false, false, true, true],
                vec![true, false, false, true],
                vec![true, false, false, false],
            ],
            3,
            Ok(None::<Vec<Vec<usize>>>)
        ),
        test_large_directed_graph_with_3_colors: (
            vec![
                vec![false, true, false, false, true, false, false, true, false, false],
                vec![false, false, true, false, false, true, false, false, true, false],
                vec![false, false, false, true, false, false, true, false, false, true],
                vec![true, false, false, false, true, false, false, true, false, false],
                vec![false, true, false, false, false, true, false, false, true, false],
                vec![false, false, true, false, false, false, true, false, false, true],
                vec![true, false, false, false, true, false, false, true, false, false],
                vec![false, true, false, false, false, true, false, false, true, false],
                vec![false, false, true, false, false, false, true, false, false, true],
                vec![true, false, false, false, true, false, false, true, false, false],
            ],
            3,
            Ok(Some(vec![
                vec![0, 1, 2, 1, 2, 0, 1, 2, 0, 1],
                vec![0, 2, 1, 2, 1, 0, 2, 1, 0, 2],
                vec![1, 0, 2, 0, 2, 1, 0, 2, 1, 0],
                vec![1, 2, 0, 2, 0, 1, 2, 0, 1, 2],
                vec![2, 0, 1, 0, 1, 2, 0, 1, 2, 0],
                vec![2, 1, 0, 1, 0, 2, 1, 0, 2, 1]
            ]))
        ),
    }
}


================================================
FILE: src/backtracking/hamiltonian_cycle.rs
================================================
//! This module provides functionality to find a Hamiltonian cycle in a directed or undirected graph.
//! Source: [Wikipedia](https://en.wikipedia.org/wiki/Hamiltonian_path_problem)

/// Represents potential errors when finding hamiltonian cycle on an adjacency matrix.
#[derive(Debug, PartialEq, Eq)]
pub enum FindHamiltonianCycleError {
    /// Indicates that the adjacency matrix is empty.
    EmptyAdjacencyMatrix,
    /// Indicates that the adjacency matrix is not square.
    ImproperAdjacencyMatrix,
    /// Indicates that the starting vertex is out of bounds.
    StartOutOfBound,
}

/// Represents a graph using an adjacency matrix.
struct Graph {
    /// The adjacency matrix representing the graph.
    adjacency_matrix: Vec<Vec<bool>>,
}

impl Graph {
    /// Creates a new graph with the provided adjacency matrix.
    ///
    /// # Arguments
    ///
    /// * `adjacency_matrix` - A square matrix where each element indicates
    ///                        the presence (`true`) or absence (`false`) of an edge
    ///                        between two vertices.
    ///
    /// # Returns
    ///
    /// A `Result` containing the graph if successful, or an `FindHamiltonianCycleError` if there is an issue with the matrix.
    fn new(adjacency_matrix: Vec<Vec<bool>>) -> Result<Self, FindHamiltonianCycleError> {
        // Check if the adjacency matrix is empty.
        if adjacency_matrix.is_empty() {
            return Err(FindHamiltonianCycleError::EmptyAdjacencyMatrix);
        }

        // Validate that the adjacency matrix is square.
        if adjacency_matrix
            .iter()
            .any(|row| row.len() != adjacency_matrix.len())
        {
            return Err(FindHamiltonianCycleError::ImproperAdjacencyMatrix);
        }

        Ok(Self { adjacency_matrix })
    }

    /// Returns the number of vertices in the graph.
    fn num_vertices(&self) -> usize {
        self.adjacency_matrix.len()
    }

    /// Determines if it is safe to include vertex `v` in the Hamiltonian cycle path.
    ///
    /// # Arguments
    ///
    /// * `v` - The index of the vertex being considered.
    /// * `visited` - A reference to the vector representing the visited vertices.
    /// * `path` - A reference to the current path being explored.
    /// * `pos` - The position of the current vertex being considered.
    ///
    /// # Returns
    ///
    /// `true` if it is safe to include `v` in the path, `false` otherwise.
    fn is_safe(&self, v: usize, visited: &[bool], path: &[Option<usize>], pos: usize) -> bool {
        // Check if the current vertex and the last vertex in the path are adjacent.
        if !self.adjacency_matrix[path[pos - 1].unwrap()][v] {
            return false;
        }

        // Check if the vertex has already been included in the path.
        !visited[v]
    }

    /// Recursively searches for a Hamiltonian cycle.
    ///
    /// This function is called by `find_hamiltonian_cycle`.
    ///
    /// # Arguments
    ///
    /// * `path` - A mutable vector representing the current path being explored.
    /// * `visited` - A mutable vector representing the visited vertices.
    /// * `pos` - The position of the current vertex being considered.
    ///
    /// # Returns
    ///
    /// `true` if a Hamiltonian cycle is found, `false` otherwise.
    fn hamiltonian_cycle_util(
        &self,
        path: &mut [Option<usize>],
        visited: &mut [bool],
        pos: usize,
    ) -> bool {
        if pos == self.num_vertices() {
            // Check if there is an edge from the last included vertex to the first vertex.
            return self.adjacency_matrix[path[pos - 1].unwrap()][path[0].unwrap()];
        }

        for v in 0..self.num_vertices() {
            if self.is_safe(v, visited, path, pos) {
                path[pos] = Some(v);
                visited[v] = true;
                if self.hamiltonian_cycle_util(path, visited, pos + 1) {
                    return true;
                }
                path[pos] = None;
                visited[v] = false;
            }
        }

        false
    }

    /// Attempts to find a Hamiltonian cycle in the graph, starting from the specified vertex.
    ///
    /// A Hamiltonian cycle visits every vertex exactly once and returns to the starting vertex.
    ///
    /// # Note
    /// This implementation may not find all possible Hamiltonian cycles.
    /// It stops as soon as it finds one valid cycle. If multiple Hamiltonian cycles exist,
    /// only one will be returned.
    ///
    /// # Returns
    ///
    /// `Ok(Some(path))` if a Hamiltonian cycle is found, where `path` is a vector
    /// containing the indices of vertices in the cycle, starting and ending with the same vertex.
    ///
    /// `Ok(None)` if no Hamiltonian cycle exists.
    fn find_hamiltonian_cycle(
        &self,
        start_vertex: usize,
    ) -> Result<Option<Vec<usize>>, FindHamiltonianCycleError> {
        // Validate the start vertex.
        if start_vertex >= self.num_vertices() {
            return Err(FindHamiltonianCycleError::StartOutOfBound);
        }

        // Initialize the path.
        let mut path = vec![None; self.num_vertices()];
        // Start at the specified vertex.
        path[0] = Some(start_vertex);

        // Initialize the visited vector.
        let mut visited = vec![false; self.num_vertices()];
        visited[start_vertex] = true;

        if self.hamiltonian_cycle_util(&mut path, &mut visited, 1) {
            // Complete the cycle by returning to the starting vertex.
            path.push(Some(start_vertex));
            Ok(Some(path.into_iter().map(Option::unwrap).collect()))
        } else {
            Ok(None)
        }
    }
}

/// Attempts to find a Hamiltonian cycle in a graph represented by an adjacency matrix, starting from a specified vertex.
pub fn find_hamiltonian_cycle(
    adjacency_matrix: Vec<Vec<bool>>,
    start_vertex: usize,
) -> Result<Option<Vec<usize>>, FindHamiltonianCycleError> {
    Graph::new(adjacency_matrix)?.find_hamiltonian_cycle(start_vertex)
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! hamiltonian_cycle_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (adjacency_matrix, start_vertex, expected) = $test_case;
                    let result = find_hamiltonian_cycle(adjacency_matrix, start_vertex);
                    assert_eq!(result, expected);
                }
            )*
        };
    }

    hamiltonian_cycle_tests! {
        test_complete_graph: (
            vec![
                vec![false, true, true, true],
                vec![true, false, true, true],
                vec![true, true, false, true],
                vec![true, true, true, false],
            ],
            0,
            Ok(Some(vec![0, 1, 2, 3, 0]))
        ),
        test_directed_graph_with_cycle: (
            vec![
                vec![false, true, false, false, false],
                vec![false, false, true, true, false],
                vec![true, false, false, true, true],
                vec![false, false, true, false, true],
                vec![true, true, false, false, false],
            ],
            2,
            Ok(Some(vec![2, 3, 4, 0, 1, 2]))
        ),
        test_undirected_graph_with_cycle: (
            vec![
                vec![false, true, false, false, true],
                vec![true, false, true, false, false],
                vec![false, true, false, true, false],
                vec![false, false, true, false, true],
                vec![true, false, false, true, false],
            ],
            2,
            Ok(Some(vec![2, 1, 0, 4, 3, 2]))
        ),
        test_directed_graph_no_cycle: (
            vec![
                vec![false, true, false, true, false],
                vec![false, false, true, true, false],
                vec![false, false, false, true, false],
                vec![false, false, false, false, true],
                vec![false, false, true, false, false],
            ],
            0,
            Ok(None::<Vec<usize>>)
        ),
        test_undirected_graph_no_cycle: (
            vec![
                vec![false, true, false, false, false],
                vec![true, false, true, true, false],
                vec![false, true, false, true, true],
                vec![false, true, true, false, true],
                vec![false, false, true, true, false],
            ],
            0,
            Ok(None::<Vec<usize>>)
        ),
        test_triangle_graph: (
            vec![
                vec![false, true, false],
                vec![false, false, true],
                vec![true, false, false],
            ],
            1,
            Ok(Some(vec![1, 2, 0, 1]))
        ),
        test_tree_graph: (
            vec![
                vec![false, true, false, true, false],
                vec![true, false, true, true, false],
                vec![false, true, false, false, false],
                vec![true, true, false, false, true],
                vec![false, false, false, true, false],
            ],
            0,
            Ok(None::<Vec<usize>>)
        ),
        test_empty_graph: (
            vec![],
            0,
            Err(FindHamiltonianCycleError::EmptyAdjacencyMatrix)
        ),
        test_improper_graph: (
            vec![
                vec![false, true],
                vec![true],
                vec![false, true, true],
                vec![true, true, true, false]
            ],
            0,
            Err(FindHamiltonianCycleError::ImproperAdjacencyMatrix)
        ),
        test_start_out_of_bound: (
            vec![
                vec![false, true, true],
                vec![true, false, true],
                vec![true, true, false],
            ],
            3,
            Err(FindHamiltonianCycleError::StartOutOfBound)
        ),
        test_complex_directed_graph: (
            vec![
                vec![false, true, false, true, false, false],
                vec![false, false, true, false, true, false],
                vec![false, false, false, true, false, false],
                vec![false, true, false, false, true, false],
                vec![false, false, true, false, false, true],
                vec![true, false, false, false, false, false],
            ],
            0,
            Ok(Some(vec![0, 1, 2, 3, 4, 5, 0]))
        ),
        single_node_self_loop: (
            vec![
                vec![true],
            ],
            0,
            Ok(Some(vec![0, 0]))
        ),
        single_node: (
            vec![
                vec![false],
            ],
            0,
            Ok(None)
        ),
    }
}


================================================
FILE: src/backtracking/knight_tour.rs
================================================
//! This module contains the implementation of the Knight's Tour problem.
//!
//! The Knight's Tour is a classic chess problem where the objective is to move a knight to every square on a chessboard exactly once.

/// Finds the Knight's Tour starting from the specified position.
///
/// # Arguments
///
/// * `size_x` - The width of the chessboard.
/// * `size_y` - The height of the chessboard.
/// * `start_x` - The x-coordinate of the starting position.
/// * `start_y` - The y-coordinate of the starting position.
///
/// # Returns
///
/// A tour matrix if the tour was found or None if not found.
/// The tour matrix returned is essentially the board field of the `KnightTour`
/// struct `Vec<Vec<usize>>`. It represents the sequence of moves made by the
/// knight on the chessboard, with each cell containing the order in which the knight visited that square.
pub fn find_knight_tour(
    size_x: usize,
    size_y: usize,
    start_x: usize,
    start_y: usize,
) -> Option<Vec<Vec<usize>>> {
    let mut tour = KnightTour::new(size_x, size_y);
    tour.find_tour(start_x, start_y)
}

/// Represents the KnightTour struct which implements the Knight's Tour problem.
struct KnightTour {
    board: Vec<Vec<usize>>,
}

impl KnightTour {
    /// Possible moves of the knight on the board
    const MOVES: [(isize, isize); 8] = [
        (2, 1),
        (1, 2),
        (-1, 2),
        (-2, 1),
        (-2, -1),
        (-1, -2),
        (1, -2),
        (2, -1),
    ];

    /// Constructs a new KnightTour instance with the given board size.
    /// # Arguments
    ///
    /// * `size_x` - The width of the chessboard.
    /// * `size_y` - The height of the chessboard.
    ///
    /// # Returns
    ///
    /// A new KnightTour instance.
    fn new(size_x: usize, size_y: usize) -> Self {
        let board = vec![vec![0; size_x]; size_y];
        KnightTour { board }
    }

    /// Returns the width of the chessboard.
    fn size_x(&self) -> usize {
        self.board.len()
    }

    /// Returns the height of the chessboard.
    fn size_y(&self) -> usize {
        self.board[0].len()
    }

    /// Checks if the given position is safe to move to.
    ///
    /// # Arguments
    ///
    /// * `x` - The x-coordinate of the position.
    /// * `y` - The y-coordinate of the position.
    ///
    /// # Returns
    ///
    /// A boolean indicating whether the position is safe to move to.
    fn is_safe(&self, x: isize, y: isize) -> bool {
        x >= 0
            && y >= 0
            && x < self.size_x() as isize
            && y < self.size_y() as isize
            && self.board[x as usize][y as usize] == 0
    }

    /// Recursively solves the Knight's Tour problem.
    ///
    /// # Arguments
    ///
    /// * `x` - The current x-coordinate of the knight.
    /// * `y` - The current y-coordinate of the knight.
    /// * `move_count` - The current move count.
    ///
    /// # Returns
    ///
    /// A boolean indicating whether a solution was found.
    fn solve_tour(&mut self, x: isize, y: isize, move_count: usize) -> bool {
        if move_count == self.size_x() * self.size_y() {
            return true;
        }
        for &(dx, dy) in &Self::MOVES {
            let next_x = x + dx;
            let next_y = y + dy;

            if self.is_safe(next_x, next_y) {
                self.board[next_x as usize][next_y as usize] = move_count + 1;

                if self.solve_tour(next_x, next_y, move_count + 1) {
                    return true;
                }
                // Backtrack
                self.board[next_x as usize][next_y as usize] = 0;
            }
        }

        false
    }

    /// Finds the Knight's Tour starting from the specified position.
    ///
    /// # Arguments
    ///
    /// * `start_x` - The x-coordinate of the starting position.
    /// * `start_y` - The y-coordinate of the starting position.
    ///
    /// # Returns
    ///
    /// A tour matrix if the tour was found or None if not found.
    fn find_tour(&mut self, start_x: usize, start_y: usize) -> Option<Vec<Vec<usize>>> {
        if !self.is_safe(start_x as isize, start_y as isize) {
            return None;
        }

        self.board[start_x][start_y] = 1;

        if !self.solve_tour(start_x as isize, start_y as isize, 1) {
            return None;
        }

        Some(self.board.clone())
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_find_knight_tour {
        ($($name:ident: $tc:expr,)*) => {
        $(
            #[test]
            fn $name() {
                let (size_x, size_y, start_x, start_y, expected) = $tc;
                if expected.is_some() {
                    assert_eq!(expected.clone().unwrap()[start_x][start_y], 1)
                }
                assert_eq!(find_knight_tour(size_x, size_y, start_x, start_y), expected);
            }
        )*
        }
    }
    test_find_knight_tour! {
        test_knight_tour_5x5: (5, 5, 0, 0, Some(vec![
            vec![1, 6, 15, 10, 21],
            vec![14, 9, 20, 5, 16],
            vec![19, 2, 7, 22, 11],
            vec![8, 13, 24, 17, 4],
            vec![25, 18, 3, 12, 23],
        ])),
        test_knight_tour_6x6: (6, 6, 0, 0, Some(vec![
            vec![1, 16, 7, 26, 11, 14],
            vec![34, 25, 12, 15, 6, 27],
            vec![17, 2, 33, 8, 13, 10],
            vec![32, 35, 24, 21, 28, 5],
            vec![23, 18, 3, 30, 9, 20],
            vec![36, 31, 22, 19, 4, 29],
        ])),
        test_knight_tour_8x8: (8, 8, 0, 0, Some(vec![
            vec![1, 60, 39, 34, 31, 18, 9, 64],
            vec![38, 35, 32, 61, 10, 63, 30, 17],
            vec![59, 2, 37, 40, 33, 28, 19, 8],
            vec![36, 49, 42, 27, 62, 11, 16, 29],
            vec![43, 58, 3, 50, 41, 24, 7, 20],
            vec![48, 51, 46, 55, 26, 21, 12, 15],
            vec![57, 44, 53, 4, 23, 14, 25, 6],
            vec![52, 47, 56, 45, 54, 5, 22, 13],
        ])),
        test_no_solution: (5, 5, 2, 1, None::<Vec<Vec<usize>>>),
        test_invalid_start_position: (8, 8, 10, 10, None::<Vec<Vec<usize>>>),
    }
}


================================================
FILE: src/backtracking/mod.rs
================================================
mod all_combination_of_size_k;
mod graph_coloring;
mod hamiltonian_cycle;
mod knight_tour;
mod n_queens;
mod parentheses_generator;
mod permutations;
mod rat_in_maze;
mod subset_sum;
mod sudoku;

pub use all_combination_of_size_k::generate_all_combinations;
pub use graph_coloring::generate_colorings;
pub use hamiltonian_cycle::find_hamiltonian_cycle;
pub use knight_tour::find_knight_tour;
pub use n_queens::n_queens_solver;
pub use parentheses_generator::generate_parentheses;
pub use permutations::permute;
pub use rat_in_maze::find_path_in_maze;
pub use subset_sum::has_subset_with_sum;
pub use sudoku::sudoku_solver;


================================================
FILE: src/backtracking/n_queens.rs
================================================
//! This module provides functionality to solve the N-Queens problem.
//!
//! The N-Queens problem is a classic chessboard puzzle where the goal is to
//! place N queens on an NxN chessboard so that no two queens threaten each
//! other. Queens can attack each other if they share the same row, column, or
//! diagonal.
//!
//! This implementation solves the N-Queens problem using a backtracking algorithm.
//! It starts with an empty chessboard and iteratively tries to place queens in
//! different rows, ensuring they do not conflict with each other. If a valid
//! solution is found, it's added to the list of solutions.

/// Solves the N-Queens problem for a given size and returns a vector of solutions.
///
/// # Arguments
///
/// * `n` - The size of the chessboard (NxN).
///
/// # Returns
///
/// A vector containing all solutions to the N-Queens problem.
pub fn n_queens_solver(n: usize) -> Vec<Vec<String>> {
    let mut solver = NQueensSolver::new(n);
    solver.solve()
}

/// Represents a solver for the N-Queens problem.
struct NQueensSolver {
    // The size of the chessboard
    size: usize,
    // A 2D vector representing the chessboard where '.' denotes an empty space and 'Q' denotes a queen
    board: Vec<Vec<char>>,
    // A vector to store all valid solutions
    solutions: Vec<Vec<String>>,
}

impl NQueensSolver {
    /// Creates a new `NQueensSolver` instance with the given size.
    ///
    /// # Arguments
    ///
    /// * `size` - The size of the chessboard (N×N).
    ///
    /// # Returns
    ///
    /// A new `NQueensSolver` instance.
    fn new(size: usize) -> Self {
        NQueensSolver {
            size,
            board: vec![vec!['.'; size]; size],
            solutions: Vec::new(),
        }
    }

    /// Solves the N-Queens problem and returns a vector of solutions.
    ///
    /// # Returns
    ///
    /// A vector containing all solutions to the N-Queens problem.
    fn solve(&mut self) -> Vec<Vec<String>> {
        self.solve_helper(0);
        std::mem::take(&mut self.solutions)
    }

    /// Checks if it's safe to place a queen at the specified position (row, col).
    ///
    /// # Arguments
    ///
    /// * `row` - The row index of the position to check.
    /// * `col` - The column index of the position to check.
    ///
    /// # Returns
    ///
    /// `true` if it's safe to place a queen at the specified position, `false` otherwise.
    fn is_safe(&self, row: usize, col: usize) -> bool {
        // Check column and diagonals
        for i in 0..row {
            if self.board[i][col] == 'Q'
                || (col >= row - i && self.board[i][col - (row - i)] == 'Q')
                || (col + row - i < self.size && self.board[i][col + (row - i)] == 'Q')
            {
                return false;
            }
        }
        true
    }

    /// Recursive helper function to solve the N-Queens problem.
    ///
    /// # Arguments
    ///
    /// * `row` - The current row being processed.
    fn solve_helper(&mut self, row: usize) {
        if row == self.size {
            self.solutions
                .push(self.board.iter().map(|row| row.iter().collect()).collect());
            return;
        }

        for col in 0..self.size {
            if self.is_safe(row, col) {
                self.board[row][col] = 'Q';
                self.solve_helper(row + 1);
                self.board[row][col] = '.';
            }
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_n_queens_solver {
        ($($name:ident: $tc:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (n, expected_solutions) = $tc;
                    let solutions = n_queens_solver(n);
                    assert_eq!(solutions, expected_solutions);
                }
            )*
        };
    }

    test_n_queens_solver! {
        test_0_queens: (0, vec![Vec::<String>::new()]),
        test_1_queen: (1, vec![vec!["Q"]]),
        test_2_queens:(2, Vec::<Vec<String>>::new()),
        test_3_queens:(3, Vec::<Vec<String>>::new()),
        test_4_queens: (4, vec![
            vec![".Q..",
                 "...Q",
                 "Q...",
                 "..Q."],
            vec!["..Q.",
                 "Q...",
                 "...Q",
                 ".Q.."],
        ]),
        test_5_queens:(5, vec![
            vec!["Q....",
                 "..Q..",
                 "....Q",
                 ".Q...",
                 "...Q."],
            vec!["Q....",
                 "...Q.",
                 ".Q...",
                 "....Q",
                 "..Q.."],
            vec![".Q...",
                 "...Q.",
                 "Q....",
                 "..Q..",
                 "....Q"],
            vec![".Q...",
                 "....Q",
                 "..Q..",
                 "Q....",
                 "...Q."],
            vec!["..Q..",
                 "Q....",
                 "...Q.",
                 ".Q...",
                 "....Q"],
            vec!["..Q..",
                 "....Q",
                 ".Q...",
                 "...Q.",
                 "Q...."],
            vec!["...Q.",
                 "Q....",
                 "..Q..",
                 "....Q",
                 ".Q..."],
            vec!["...Q.",
                 ".Q...",
                 "....Q",
                 "..Q..",
                 "Q...."],
            vec!["....Q",
                 ".Q...",
                 "...Q.",
                 "Q....",
                 "..Q.."],
            vec!["....Q",
                 "..Q..",
                 "Q....",
                 "...Q.",
                 ".Q..."],
        ]),
        test_6_queens: (6, vec![
            vec![".Q....",
                 "...Q..",
                 ".....Q",
                 "Q.....",
                 "..Q...",
                 "....Q."],
            vec!["..Q...",
                 ".....Q",
                 ".Q....",
                 "....Q.",
                 "Q.....",
                 "...Q.."],
            vec!["...Q..",
                 "Q.....",
                 "....Q.",
                 ".Q....",
                 ".....Q",
                 "..Q..."],
            vec!["....Q.",
                 "..Q...",
                 "Q.....",
                 ".....Q",
                 "...Q..",
                 ".Q...."],
        ]),
    }
}


================================================
FILE: src/backtracking/parentheses_generator.rs
================================================
/// Generates all combinations of well-formed parentheses given a non-negative integer `n`.
///
/// This function uses backtracking to generate all possible combinations of well-formed
/// parentheses. The resulting combinations are returned as a vector of strings.
///
/// # Arguments
///
/// * `n` - A non-negative integer representing the number of pairs of parentheses.
pub fn generate_parentheses(n: usize) -> Vec<String> {
    let mut result = Vec::new();
    if n > 0 {
        generate("", 0, 0, n, &mut result);
    }
    result
}

/// Helper function for generating parentheses recursively.
///
/// This function is called recursively to build combinations of well-formed parentheses.
/// It tracks the number of open and close parentheses added so far and adds a new parenthesis
/// if it's valid to do so.
///
/// # Arguments
///
/// * `current` - The current string of parentheses being built.
/// * `open_count` - The count of open parentheses in the current string.
/// * `close_count` - The count of close parentheses in the current string.
/// * `n` - The total number of pairs of parentheses to be generated.
/// * `result` - A mutable reference to the vector storing the generated combinations.
fn generate(
    current: &str,
    open_count: usize,
    close_count: usize,
    n: usize,
    result: &mut Vec<String>,
) {
    if current.len() == (n * 2) {
        result.push(current.to_string());
        return;
    }

    if open_count < n {
        let new_str = current.to_string() + "(";
        generate(&new_str, open_count + 1, close_count, n, result);
    }

    if close_count < open_count {
        let new_str = current.to_string() + ")";
        generate(&new_str, open_count, close_count + 1, n, result);
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! generate_parentheses_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (n, expected_result) = $test_case;
                    assert_eq!(generate_parentheses(n), expected_result);
                }
            )*
        };
    }

    generate_parentheses_tests! {
        test_generate_parentheses_0: (0, Vec::<String>::new()),
        test_generate_parentheses_1: (1, vec!["()"]),
        test_generate_parentheses_2: (2, vec!["(())", "()()"]),
        test_generate_parentheses_3: (3, vec!["((()))", "(()())", "(())()", "()(())", "()()()"]),
        test_generate_parentheses_4: (4, vec!["(((())))", "((()()))", "((())())", "((()))()", "(()(()))", "(()()())", "(()())()", "(())(())", "(())()()", "()((()))", "()(()())", "()(())()", "()()(())", "()()()()"]),
    }
}


================================================
FILE: src/backtracking/permutations.rs
================================================
//! This module provides a function to generate all possible distinct permutations
//! of a given collection of integers using a backtracking algorithm.

/// Generates all possible distinct permutations of a given vector of integers.
///
/// # Arguments
///
/// * `nums` - A vector of integers. The input vector is sorted before generating
/// permutations to handle duplicates effectively.
///
/// # Returns
///
/// A vector containing all possible distinct permutations of the input vector.
pub fn permute(mut nums: Vec<isize>) -> Vec<Vec<isize>> {
    let mut permutations = Vec::new();
    let mut current = Vec::new();
    let mut used = vec![false; nums.len()];

    nums.sort();
    generate(&nums, &mut current, &mut used, &mut permutations);

    permutations
}

/// Helper function for the `permute` function to generate distinct permutations recursively.
///
/// # Arguments
///
/// * `nums` - A reference to the sorted slice of integers.
/// * `current` - A mutable reference to the vector holding the current permutation.
/// * `used` - A mutable reference to a vector tracking which elements are used.
/// * `permutations` - A mutable reference to the vector holding all generated distinct permutations.
fn generate(
    nums: &[isize],
    current: &mut Vec<isize>,
    used: &mut Vec<bool>,
    permutations: &mut Vec<Vec<isize>>,
) {
    if current.len() == nums.len() {
        permutations.push(current.clone());
        return;
    }

    for idx in 0..nums.len() {
        if used[idx] {
            continue;
        }

        if idx > 0 && nums[idx] == nums[idx - 1] && !used[idx - 1] {
            continue;
        }

        current.push(nums[idx]);
        used[idx] = true;

        generate(nums, current, used, permutations);

        current.pop();
        used[idx] = false;
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! permute_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (input, expected) = $test_case;
                    assert_eq!(permute(input), expected);
                }
            )*
        }
    }

    permute_tests! {
        test_permute_basic: (vec![1, 2, 3], vec![
            vec![1, 2, 3],
            vec![1, 3, 2],
            vec![2, 1, 3],
            vec![2, 3, 1],
            vec![3, 1, 2],
            vec![3, 2, 1],
        ]),
        test_permute_empty: (Vec::<isize>::new(), vec![vec![]]),
        test_permute_single: (vec![1], vec![vec![1]]),
        test_permute_duplicates: (vec![1, 1, 2], vec![
            vec![1, 1, 2],
            vec![1, 2, 1],
            vec![2, 1, 1],
        ]),
        test_permute_all_duplicates: (vec![1, 1, 1, 1], vec![
            vec![1, 1, 1, 1],
        ]),
        test_permute_negative: (vec![-1, -2, -3], vec![
            vec![-3, -2, -1],
            vec![-3, -1, -2],
            vec![-2, -3, -1],
            vec![-2, -1, -3],
            vec![-1, -3, -2],
            vec![-1, -2, -3],
        ]),
        test_permute_mixed: (vec![-1, 0, 1], vec![
            vec![-1, 0, 1],
            vec![-1, 1, 0],
            vec![0, -1, 1],
            vec![0, 1, -1],
            vec![1, -1, 0],
            vec![1, 0, -1],
        ]),
        test_permute_larger: (vec![1, 2, 3, 4], vec![
            vec![1, 2, 3, 4],
            vec![1, 2, 4, 3],
            vec![1, 3, 2, 4],
            vec![1, 3, 4, 2],
            vec![1, 4, 2, 3],
            vec![1, 4, 3, 2],
            vec![2, 1, 3, 4],
            vec![2, 1, 4, 3],
            vec![2, 3, 1, 4],
            vec![2, 3, 4, 1],
            vec![2, 4, 1, 3],
            vec![2, 4, 3, 1],
            vec![3, 1, 2, 4],
            vec![3, 1, 4, 2],
            vec![3, 2, 1, 4],
            vec![3, 2, 4, 1],
            vec![3, 4, 1, 2],
            vec![3, 4, 2, 1],
            vec![4, 1, 2, 3],
            vec![4, 1, 3, 2],
            vec![4, 2, 1, 3],
            vec![4, 2, 3, 1],
            vec![4, 3, 1, 2],
            vec![4, 3, 2, 1],
        ]),
    }
}


================================================
FILE: src/backtracking/rat_in_maze.rs
================================================
//! This module contains the implementation of the Rat in Maze problem.
//!
//! The Rat in Maze problem is a classic algorithmic problem where the
//! objective is to find a path from the starting position to the exit
//! position in a maze.

/// Enum representing various errors that can occur while working with mazes.
#[derive(Debug, PartialEq, Eq)]
pub enum MazeError {
    /// Indicates that the maze is empty (zero rows).
    EmptyMaze,
    /// Indicates that the starting position is out of bounds.
    OutOfBoundPos,
    /// Indicates an improper representation of the maze (e.g., non-rectangular maze).
    ImproperMazeRepr,
}

/// Finds a path through the maze starting from the specified position.
///
/// # Arguments
///
/// * `maze` - The maze represented as a vector of vectors where each
/// inner vector represents a row in the maze grid.
/// * `start_x` - The x-coordinate of the starting position.
/// * `start_y` - The y-coordinate of the starting position.
///
/// # Returns
///
/// A `Result` where:
/// - `Ok(Some(solution))` if a path is found and contains the solution matrix.
/// - `Ok(None)` if no path is found.
/// - `Err(MazeError)` for various error conditions such as out-of-bound start position or improper maze representation.
///
/// # Solution Selection
///
/// The function returns the first successful path it discovers based on the predefined order of moves.
/// The order of moves is defined in the `MOVES` constant of the `Maze` struct.
///
/// The backtracking algorithm explores each direction in this order. If multiple solutions exist,
/// the algorithm returns the first path it finds according to this sequence. It recursively explores
/// each direction, marks valid moves, and backtracks if necessary, ensuring that the solution is found
/// efficiently and consistently.
pub fn find_path_in_maze(
    maze: &[Vec<bool>],
    start_x: usize,
    start_y: usize,
) -> Result<Option<Vec<Vec<bool>>>, MazeError> {
    if maze.is_empty() {
        return Err(MazeError::EmptyMaze);
    }

    // Validate start position
    if start_x >= maze.len() || start_y >= maze[0].len() {
        return Err(MazeError::OutOfBoundPos);
    }

    // Validate maze representation (if necessary)
    if maze.iter().any(|row| row.len() != maze[0].len()) {
        return Err(MazeError::ImproperMazeRepr);
    }

    // If validations pass, proceed with finding the path
    let maze_instance = Maze::new(maze.to_owned());
    Ok(maze_instance.find_path(start_x, start_y))
}

/// Represents a maze.
struct Maze {
    maze: Vec<Vec<bool>>,
}

impl Maze {
    /// Represents possible moves in the maze.
    const MOVES: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)];

    /// Constructs a new Maze instance.
    /// # Arguments
    ///
    /// * `maze` - The maze represented as a vector of vectors where each
    /// inner vector represents a row in the maze grid.
    ///
    /// # Returns
    ///
    /// A new Maze instance.
    fn new(maze: Vec<Vec<bool>>) -> Self {
        Maze { maze }
    }

    /// Returns the width of the maze.
    ///
    /// # Returns
    ///
    /// The width of the maze.
    fn width(&self) -> usize {
        self.maze[0].len()
    }

    /// Returns the height of the maze.
    ///
    /// # Returns
    ///
    /// The height of the maze.
    fn height(&self) -> usize {
        self.maze.len()
    }

    /// Finds a path through the maze starting from the specified position.
    ///
    /// # Arguments
    ///
    /// * `start_x` - The x-coordinate of the starting position.
    /// * `start_y` - The y-coordinate of the starting position.
    ///
    /// # Returns
    ///
    /// A solution matrix if a path is found or None if not found.
    fn find_path(&self, start_x: usize, start_y: usize) -> Option<Vec<Vec<bool>>> {
        let mut solution = vec![vec![false; self.width()]; self.height()];
        if self.solve(start_x as isize, start_y as isize, &mut solution) {
            Some(solution)
        } else {
            None
        }
    }

    /// Recursively solves the Rat in Maze problem using backtracking.
    ///
    /// # Arguments
    ///
    /// * `x` - The current x-coordinate.
    /// * `y` - The current y-coordinate.
    /// * `solution` - The current solution matrix.
    ///
    /// # Returns
    ///
    /// A boolean indicating whether a solution was found.
    fn solve(&self, x: isize, y: isize, solution: &mut [Vec<bool>]) -> bool {
        if x == (self.height() as isize - 1) && y == (self.width() as isize - 1) {
            solution[x as usize][y as usize] = true;
            return true;
        }

        if self.is_valid(x, y, solution) {
            solution[x as usize][y as usize] = true;

            for &(dx, dy) in &Self::MOVES {
                if self.solve(x + dx, y + dy, solution) {
                    return true;
                }
            }

            // If none of the directions lead to the solution, backtrack
            solution[x as usize][y as usize] = false;
            return false;
        }
        false
    }

    /// Checks if a given position is valid in the maze.
    ///
    /// # Arguments
    ///
    /// * `x` - The x-coordinate of the position.
    /// * `y` - The y-coordinate of the position.
    /// * `solution` - The current solution matrix.
    ///
    /// # Returns
    ///
    /// A boolean indicating whether the position is valid.
    fn is_valid(&self, x: isize, y: isize, solution: &[Vec<bool>]) -> bool {
        x >= 0
            && y >= 0
            && x < self.height() as isize
            && y < self.width() as isize
            && self.maze[x as usize][y as usize]
            && !solution[x as usize][y as usize]
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_find_path_in_maze {
        ($($name:ident: $start_x:expr, $start_y:expr, $maze:expr, $expected:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let solution = find_path_in_maze($maze, $start_x, $start_y);
                    assert_eq!(solution, $expected);
                    if let Ok(Some(expected_solution)) = &solution {
                        assert_eq!(expected_solution[$start_x][$start_y], true);
                    }
                }
            )*
        }
    }

    test_find_path_in_maze! {
        maze_with_solution_5x5: 0, 0, &[
            vec![true, false, true, false, false],
            vec![true, true, false, true, false],
            vec![false, true, true, true, false],
            vec![false, false, false, true, true],
            vec![false, true, false, false, true],
        ], Ok(Some(vec![
            vec![true, false, false, false, false],
            vec![true, true, false, false, false],
            vec![false, true, true, true, false],
            vec![false, false, false, true, true],
            vec![false, false, false, false, true],
        ])),
        maze_with_solution_6x6: 0, 0, &[
            vec![true, false, true, false, true, false],
            vec![true, true, false, true, false, true],
            vec![false, true, true, true, true, false],
            vec![false, false, false, true, true, true],
            vec![false, true, false, false, true, false],
            vec![true, true, true, true, true, true],
        ], Ok(Some(vec![
            vec![true, false, false, false, false, false],
            vec![true, true, false, false, false, false],
            vec![false, true, true, true, true, false],
            vec![false, false, false, false, true, false],
            vec![false, false, false, false, true, false],
            vec![false, false, false, false, true, true],
        ])),
        maze_with_solution_8x8: 0, 0, &[
            vec![true, false, false, false, false, false, false, true],
            vec![true, true, false, true, true, true, false, false],
            vec![false, true, true, true, false, false, false, false],
            vec![false, false, false, true, false, true, true, false],
            vec![false, true, false, true, true, true, false, true],
            vec![true, false, true, false, false, true, true, true],
            vec![false, false, true, true, true, false, true, true],
            vec![true, true, true, false, true, true, true, true],
        ], Ok(Some(vec![
            vec![true, false, false, false, false, false, false, false],
            vec![true, true, false, false, false, false, false, false],
            vec![false, true, true, true, false, false, false, false],
            vec![false, false, false, true, false, false, false, false],
            vec![false, false, false, true, true, true, false, false],
            vec![false, false, false, false, false, true, true, true],
            vec![false, false, false, false, false, false, false, true],
            vec![false, false, false, false, false, false, false, true],
        ])),
        maze_without_solution_4x4: 0, 0, &[
            vec![true, false, false, false],
            vec![true, true, false, false],
            vec![false, false, true, false],
            vec![false, false, false, true],
        ], Ok(None::<Vec<Vec<bool>>>),
        maze_with_solution_3x4: 0, 0, &[
            vec![true, false, true, true],
            vec![true, true, true, false],
            vec![false, true, true, true],
        ], Ok(Some(vec![
            vec![true, false, false, false],
            vec![true, true, true, false],
            vec![false, false, true, true],
        ])),
        maze_without_solution_3x4: 0, 0, &[
            vec![true, false, true, true],
            vec![true, false, true, false],
            vec![false, true, false, true],
        ], Ok(None::<Vec<Vec<bool>>>),
        improper_maze_representation: 0, 0, &[
            vec![true],
            vec![true, true],
            vec![true, true, true],
            vec![true, true, true, true]
        ], Err(MazeError::ImproperMazeRepr),
        out_of_bound_start: 0, 3, &[
            vec![true, false, true],
            vec![true, true],
            vec![false, true, true],
        ], Err(MazeError::OutOfBoundPos),
        empty_maze: 0, 0, &[], Err(MazeError::EmptyMaze),
        maze_with_single_cell: 0, 0, &[
            vec![true],
        ], Ok(Some(vec![
                vec![true]
        ])),
        maze_with_one_row_and_multiple_columns: 0, 0, &[
            vec![true, false, true, true, false]
        ], Ok(None::<Vec<Vec<bool>>>),
        maze_with_multiple_rows_and_one_column: 0, 0, &[
            vec![true],
            vec![true],
            vec![false],
            vec![true],
        ], Ok(None::<Vec<Vec<bool>>>),
        maze_with_walls_surrounding_border: 0, 0, &[
            vec![false, false, false],
            vec![false, true, false],
            vec![false, false, false],
        ], Ok(None::<Vec<Vec<bool>>>),
        maze_with_no_walls: 0, 0, &[
            vec![true, true, true],
            vec![true, true, true],
            vec![true, true, true],
        ], Ok(Some(vec![
            vec![true, true, true],
            vec![false, false, true],
            vec![false, false, true],
        ])),
        maze_with_going_back: 0, 0, &[
            vec![true,  true,  true,  true, true,   true],
            vec![false, false, false, true, false,  true],
            vec![true,  true,  true,  true,  false, false],
            vec![true,  false, false, false, false, false],
            vec![true,  false, false, false, true, true],
            vec![true,  false, true,  true,  true,  false],
            vec![true,  false, true , false, true,  false],
            vec![true,  true,  true,  false, true,  true],
        ], Ok(Some(vec![
            vec![true,  true,  true,  true, false,  false],
            vec![false, false, false, true, false,  false],
            vec![true,  true,  true,  true,  false, false],
            vec![true,  false, false, false, false, false],
            vec![true,  false, false, false, false, false],
            vec![true,  false, true,  true,  true,  false],
            vec![true,  false, true , false, true,  false],
            vec![true,  true,  true,  false, true,  true],
        ])),
    }
}


================================================
FILE: src/backtracking/subset_sum.rs
================================================
//! This module provides functionality to check if there exists a subset of a given set of integers
//! that sums to a target value. The implementation uses a recursive backtracking approach.

/// Checks if there exists a subset of the given set that sums to the target value.
pub fn has_subset_with_sum(set: &[isize], target: isize) -> bool {
    backtrack(set, set.len(), target)
}

fn backtrack(set: &[isize], remaining_items: usize, target: isize) -> bool {
    // Found a subset with the required sum
    if target == 0 {
        return true;
    }
    // No more elements to process
    if remaining_items == 0 {
        return false;
    }
    // Check if we can find a subset including or excluding the last element
    backtrack(set, remaining_items - 1, target)
        || backtrack(set, remaining_items - 1, target - set[remaining_items - 1])
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! has_subset_with_sum_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (set, target, expected) = $test_case;
                    assert_eq!(has_subset_with_sum(set, target), expected);
                }
            )*
        }
    }

    has_subset_with_sum_tests! {
        test_small_set_with_sum: (&[3, 34, 4, 12, 5, 2], 9, true),
        test_small_set_without_sum: (&[3, 34, 4, 12, 5, 2], 30, false),
        test_consecutive_set_with_sum: (&[1, 2, 3, 4, 5, 6], 10, true),
        test_consecutive_set_without_sum: (&[1, 2, 3, 4, 5, 6], 22, false),
        test_large_set_with_sum: (&[5, 10, 12, 13, 15, 18, -1, 10, 50, -2, 3, 4], 30, true),
        test_empty_set: (&[], 0, true),
        test_empty_set_with_nonzero_sum: (&[], 10, false),
        test_single_element_equal_to_sum: (&[10], 10, true),
        test_single_element_not_equal_to_sum: (&[5], 10, false),
        test_negative_set_with_sum: (&[-7, -3, -2, 5, 8], 0, true),
        test_negative_sum: (&[1, 2, 3, 4, 5], -1, false),
        test_negative_sum_with_negatives: (&[-7, -3, -2, 5, 8], -4, true),
        test_negative_sum_with_negatives_no_solution: (&[-7, -3, -2, 5, 8], -14, false),
        test_even_inputs_odd_target: (&[2, 4, 6, 2, 8, -2, 10, 12, -24, 8, 12, 18], 3, false),
    }
}


================================================
FILE: src/backtracking/sudoku.rs
================================================
//! A Rust implementation of Sudoku solver using Backtracking.
//!
//! This module provides functionality to solve Sudoku puzzles using the backtracking algorithm.
//!
//! GeeksForGeeks: [Sudoku Backtracking](https://www.geeksforgeeks.org/sudoku-backtracking-7/)

/// Solves a Sudoku puzzle.
///
/// Given a partially filled Sudoku puzzle represented by a 9x9 grid, this function attempts to
/// solve the puzzle using the backtracking algorithm.
///
/// Returns the solved Sudoku board if a solution exists, or `None` if no solution is found.
pub fn sudoku_solver(board: &[[u8; 9]; 9]) -> Option<[[u8; 9]; 9]> {
    let mut solver = SudokuSolver::new(*board);
    if solver.solve() {
        Some(solver.board)
    } else {
        None
    }
}

/// Represents a Sudoku puzzle solver.
struct SudokuSolver {
    /// The Sudoku board represented by a 9x9 grid.
    board: [[u8; 9]; 9],
}

impl SudokuSolver {
    /// Creates a new Sudoku puzzle solver with the given board.
    fn new(board: [[u8; 9]; 9]) -> SudokuSolver {
        SudokuSolver { board }
    }

    /// Finds an empty cell in the Sudoku board.
    ///
    /// Returns the coordinates of an empty cell `(row, column)` if found, or `None` if all cells are filled.
    fn find_empty_cell(&self) -> Option<(usize, usize)> {
        // Find an empty cell in the board (returns None if all cells are filled)
        for row in 0..9 {
            for column in 0..9 {
                if self.board[row][column] == 0 {
                    return Some((row, column));
                }
            }
        }

        None
    }

    /// Checks whether a given value can be placed in a specific cell according to Sudoku rules.
    ///
    /// Returns `true` if the value can be placed in the cell, otherwise `false`.
    fn is_value_valid(&self, coordinates: (usize, usize), value: u8) -> bool {
        let (row, column) = coordinates;

        // Checks if the value to be added in the board is an acceptable value for the cell
        // Checking through the row
        for current_column in 0..9 {
            if self.board[row][current_column] == value {
                return false;
            }
        }

        // Checking through the column
        for current_row in 0..9 {
            if self.board[current_row][column] == value {
                return false;
            }
        }

        // Checking through the 3x3 block of the cell
        let start_row = row / 3 * 3;
        let start_column = column / 3 * 3;

        for current_row in start_row..start_row + 3 {
            for current_column in start_column..start_column + 3 {
                if self.board[current_row][current_column] == value {
                    return false;
                }
            }
        }

        true
    }

    /// Solves the Sudoku puzzle recursively using backtracking.
    ///
    /// Returns `true` if a solution is found, otherwise `false`.
    fn solve(&mut self) -> bool {
        let empty_cell = self.find_empty_cell();

        if let Some((row, column)) = empty_cell {
            for value in 1..=9 {
                if self.is_value_valid((row, column), value) {
                    self.board[row][column] = value;
                    if self.solve() {
                        return true;
                    }
                    // Backtracking if the board cannot be solved using the current configuration
                    self.board[row][column] = 0;
                }
            }
        } else {
            // If the board is complete
            return true;
        }

        // Returning false if the board cannot be solved using the current configuration
        false
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_sudoku_solver {
        ($($name:ident: $board:expr, $expected:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let result = sudoku_solver(&$board);
                    assert_eq!(result, $expected);
                }
            )*
        };
    }

    test_sudoku_solver! {
        test_sudoku_correct: [
            [3, 0, 6, 5, 0, 8, 4, 0, 0],
            [5, 2, 0, 0, 0, 0, 0, 0, 0],
            [0, 8, 7, 0, 0, 0, 0, 3, 1],
            [0, 0, 3, 0, 1, 0, 0, 8, 0],
            [9, 0, 0, 8, 6, 3, 0, 0, 5],
            [0, 5, 0, 0, 9, 0, 6, 0, 0],
            [1, 3, 0, 0, 0, 0, 2, 5, 0],
            [0, 0, 0, 0, 0, 0, 0, 7, 4],
            [0, 0, 5, 2, 0, 6, 3, 0, 0],
        ], Some([
            [3, 1, 6, 5, 7, 8, 4, 9, 2],
            [5, 2, 9, 1, 3, 4, 7, 6, 8],
            [4, 8, 7, 6, 2, 9, 5, 3, 1],
            [2, 6, 3, 4, 1, 5, 9, 8, 7],
            [9, 7, 4, 8, 6, 3, 1, 2, 5],
            [8, 5, 1, 7, 9, 2, 6, 4, 3],
            [1, 3, 8, 9, 4, 7, 2, 5, 6],
            [6, 9, 2, 3, 5, 1, 8, 7, 4],
            [7, 4, 5, 2, 8, 6, 3, 1, 9],
        ]),

        test_sudoku_incorrect: [
            [6, 0, 3, 5, 0, 8, 4, 0, 0],
            [5, 2, 0, 0, 0, 0, 0, 0, 0],
            [0, 8, 7, 0, 0, 0, 0, 3, 1],
            [0, 0, 3, 0, 1, 0, 0, 8, 0],
            [9, 0, 0, 8, 6, 3, 0, 0, 5],
            [0, 5, 0, 0, 9, 0, 6, 0, 0],
            [1, 3, 0, 0, 0, 0, 2, 5, 0],
            [0, 0, 0, 0, 0, 0, 0, 7, 4],
            [0, 0, 5, 2, 0, 6, 3, 0, 0],
        ], None::<[[u8; 9]; 9]>,
    }
}


================================================
FILE: src/big_integer/fast_factorial.rs
================================================
// Algorithm created by Peter Borwein in 1985
// https://doi.org/10.1016/0196-6774(85)90006-9

use crate::math::sieve_of_eratosthenes;
use num_bigint::BigUint;
use num_traits::One;
use std::collections::BTreeMap;

/// Calculate the sum of n / p^i with integer division for all values of i
fn index(p: usize, n: usize) -> usize {
    let mut index = 0;
    let mut i = 1;
    let mut quot = n / p;

    while quot > 0 {
        index += quot;
        i += 1;
        quot = n / p.pow(i);
    }

    index
}

/// Calculate the factorial with time complexity O(log(log(n)) * M(n * log(n))) where M(n) is the time complexity of multiplying two n-digit numbers together.
pub fn fast_factorial(n: usize) -> BigUint {
    if n < 2 {
        return BigUint::one();
    }

    // get list of primes that will be factors of n!
    let primes = sieve_of_eratosthenes(n);

    // Map the primes with their index
    let p_indices = primes
        .into_iter()
        .map(|p| (p, index(p, n)))
        .collect::<BTreeMap<_, _>>();

    let max_bits = p_indices[&2].next_power_of_two().ilog2() + 1;

    // Create a Vec of 1's
    let mut a = vec![BigUint::one(); max_bits as usize];

    // For every prime p, multiply a[i] by p if the ith bit of p's index is 1
    for (p, i) in p_indices {
        let mut bit = 1usize;
        while bit.ilog2() < max_bits {
            if (bit & i) > 0 {
                a[bit.ilog2() as usize] *= p;
            }

            bit <<= 1;
        }
    }

    a.into_iter()
        .enumerate()
        .map(|(i, a_i)| a_i.pow(2u32.pow(i as u32))) // raise every a[i] to the 2^ith power
        .product() // we get our answer by multiplying the result
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::math::factorial::factorial_bigmath;

    #[test]
    fn fact() {
        assert_eq!(fast_factorial(0), BigUint::one());
        assert_eq!(fast_factorial(1), BigUint::one());
        assert_eq!(fast_factorial(2), factorial_bigmath(2));
        assert_eq!(fast_factorial(3), factorial_bigmath(3));
        assert_eq!(fast_factorial(6), factorial_bigmath(6));
        assert_eq!(fast_factorial(7), factorial_bigmath(7));
        assert_eq!(fast_factorial(10), factorial_bigmath(10));
        assert_eq!(fast_factorial(11), factorial_bigmath(11));
        assert_eq!(fast_factorial(18), factorial_bigmath(18));
        assert_eq!(fast_factorial(19), factorial_bigmath(19));
        assert_eq!(fast_factorial(30), factorial_bigmath(30));
        assert_eq!(fast_factorial(34), factorial_bigmath(34));
        assert_eq!(fast_factorial(35), factorial_bigmath(35));
        assert_eq!(fast_factorial(52), factorial_bigmath(52));
        assert_eq!(fast_factorial(100), factorial_bigmath(100));
        assert_eq!(fast_factorial(1000), factorial_bigmath(1000));
        assert_eq!(fast_factorial(5000), factorial_bigmath(5000));
    }
}


================================================
FILE: src/big_integer/mod.rs
================================================
#![cfg(feature = "big-math")]

mod fast_factorial;
mod multiply;
mod poly1305;

pub use self::fast_factorial::fast_factorial;
pub use self::multiply::multiply;
pub use self::poly1305::Poly1305;


================================================
FILE: src/big_integer/multiply.rs
================================================
/// Performs long multiplication on string representations of non-negative numbers.
pub fn multiply(num1: &str, num2: &str) -> String {
    if !is_valid_nonnegative(num1) || !is_valid_nonnegative(num2) {
        panic!("String does not conform to specification")
    }

    if num1 == "0" || num2 == "0" {
        return "0".to_string();
    }
    let output_size = num1.len() + num2.len();

    let mut mult = vec![0; output_size];
    for (i, c1) in num1.chars().rev().enumerate() {
        for (j, c2) in num2.chars().rev().enumerate() {
            let mul = c1.to_digit(10).unwrap() * c2.to_digit(10).unwrap();
            // It could be a two-digit number here.
            mult[i + j + 1] += (mult[i + j] + mul) / 10;
            // Handling rounding. Here's a single digit.
            mult[i + j] = (mult[i + j] + mul) % 10;
        }
    }
    if mult[output_size - 1] == 0 {
        mult.pop();
    }
    mult.iter().rev().map(|&n| n.to_string()).collect()
}

pub fn is_valid_nonnegative(num: &str) -> bool {
    num.chars().all(char::is_numeric) && !num.is_empty() && (!num.starts_with('0') || num == "0")
}

#[cfg(test)]
mod tests {
    use super::*;
    macro_rules! test_multiply {
        ($($name:ident: $inputs:expr,)*) => {
        $(
            #[test]
            fn $name() {
                let (s, t, expected) = $inputs;
                assert_eq!(multiply(s, t), expected);
                assert_eq!(multiply(t, s), expected);
            }
        )*
        }
    }

    test_multiply! {
        multiply0: ("2", "3", "6"),
        multiply1: ("123", "456", "56088"),
        multiply_zero: ("0", "222", "0"),
        other_1: ("99", "99", "9801"),
        other_2: ("999", "99", "98901"),
        other_3: ("9999", "99", "989901"),
        other_4: ("192939", "9499596", "1832842552644"),
    }

    macro_rules! test_multiply_with_wrong_input {
        ($($name:ident: $inputs:expr,)*) => {
        $(
            #[test]
            #[should_panic]
            fn $name() {
                let (s, t) = $inputs;
                multiply(s, t);
            }
        )*
        }
    }
    test_multiply_with_wrong_input! {
        empty_input: ("", "121"),
        leading_zero: ("01", "3"),
        wrong_characters: ("2", "12d4"),
        wrong_input_and_zero_1: ("0", "x"),
        wrong_input_and_zero_2: ("y", "0"),
    }
}


================================================
FILE: src/big_integer/poly1305.rs
================================================
use num_bigint::BigUint;
use num_traits::Num;
use num_traits::Zero;

macro_rules! hex_uint {
    ($a:literal) => {
        BigUint::from_str_radix($a, 16).unwrap()
    };
}

/**
 * Poly1305 Message Authentication Code:
 * This implementation is based on RFC8439.
 * Note that the Big Integer library we are using may not be suitable for
 * cryptographic applications due to non constant time operations.
*/
pub struct Poly1305 {
    p: BigUint,
    r: BigUint,
    s: BigUint,
    /// The accumulator
    pub acc: BigUint,
}

impl Default for Poly1305 {
    fn default() -> Self {
        Self::new()
    }
}

impl Poly1305 {
    pub fn new() -> Self {
        Poly1305 {
            p: hex_uint!("3fffffffffffffffffffffffffffffffb"), // 2^130 - 5
            r: Zero::zero(),
            s: Zero::zero(),
            acc: Zero::zero(),
        }
    }
    pub fn clamp_r(&mut self) {
        self.r &= hex_uint!("0ffffffc0ffffffc0ffffffc0fffffff");
    }
    pub fn set_key(&mut self, key: &[u8; 32]) {
        self.r = BigUint::from_bytes_le(&key[..16]);
        self.s = BigUint::from_bytes_le(&key[16..]);
        self.clamp_r();
    }
    /// process a 16-byte-long message block. If message is not long enough,
    /// fill the `msg` array with zeros, but set `msg_bytes` to the original
    /// chunk length in bytes. See `basic_tv1` for example usage.
    pub fn add_msg(&mut self, msg: &[u8; 16], msg_bytes: u64) {
        let mut n = BigUint::from_bytes_le(msg);
        n.set_bit(msg_bytes * 8, true);
        self.acc += n;
        self.acc *= &self.r;
        self.acc %= &self.p;
    }
    /// The result is guaranteed to be 16 bytes long
    pub fn get_tag(&self) -> Vec<u8> {
        let result = &self.acc + &self.s;
        let mut bytes = result.to_bytes_le();
        bytes.resize(16, 0);
        bytes
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::fmt::Write;
    fn get_tag_hex(tag: &[u8]) -> String {
        let mut result = String::new();
        for &x in tag {
            write!(result, "{x:02x}").unwrap();
        }
        result
    }
    #[test]
    fn basic_tv1() {
        let mut mac = Poly1305::default();
        let key: [u8; 32] = [
            0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33, 0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5,
            0x06, 0xa8, 0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd, 0x4a, 0xbf, 0xf6, 0xaf,
            0x41, 0x49, 0xf5, 0x1b,
        ];
        let mut tmp_buffer = [0_u8; 16];
        mac.set_key(&key);
        mac.add_msg(b"Cryptographic Fo", 16);
        mac.add_msg(b"rum Research Gro", 16);
        tmp_buffer[..2].copy_from_slice(b"up");
        mac.add_msg(&tmp_buffer, 2);
        let result = mac.get_tag();
        assert_eq!(
            get_tag_hex(result.as_slice()),
            "a8061dc1305136c6c22b8baf0c0127a9"
        );
    }
}


================================================
FILE: src/bit_manipulation/binary_coded_decimal.rs
================================================
//! Binary Coded Decimal (BCD) conversion
//!
//! This module provides a function to convert decimal integers to Binary Coded Decimal (BCD) format.
//! In BCD, each decimal digit is represented by its 4-bit binary equivalent.
//!
//! # Examples
//!
//! ```
//! use the_algorithms_rust::bit_manipulation::binary_coded_decimal;
//!
//! assert_eq!(binary_coded_decimal(12), "0b00010010");
//! assert_eq!(binary_coded_decimal(987), "0b100110000111");
//! ```

use std::fmt::Write;

/// Converts a decimal integer to Binary Coded Decimal (BCD) format.
///
/// Each digit of the input number is represented by a 4-bit binary value.
/// Negative numbers are treated as 0.
///
/// # Arguments
///
/// * `number` - An integer to be converted to BCD format
///
/// # Returns
///
/// A `String` representing the BCD encoding with "0b" prefix
///
/// # Examples
///
/// ```
/// use the_algorithms_rust::bit_manipulation::binary_coded_decimal;
///
/// assert_eq!(binary_coded_decimal(0), "0b0000");
/// assert_eq!(binary_coded_decimal(3), "0b0011");
/// assert_eq!(binary_coded_decimal(12), "0b00010010");
/// assert_eq!(binary_coded_decimal(987), "0b100110000111");
/// assert_eq!(binary_coded_decimal(-5), "0b0000");
/// ```
///
/// # Algorithm
///
/// 1. Convert the number to its absolute value (negative numbers become 0)
/// 2. For each decimal digit:
///    - Convert the digit to binary
///    - Pad to 4 bits with leading zeros
///    - Concatenate to the result
/// 3. Prepend "0b" to the final binary string
pub fn binary_coded_decimal(number: i32) -> String {
    // Handle negative numbers by converting to 0
    let num = if number < 0 { 0 } else { number };

    // Convert to string to process each digit
    let digits = num.to_string();

    // Build the BCD string using fold for efficiency
    let bcd = digits.chars().fold(String::new(), |mut acc, digit| {
        // Convert char to digit value and format as 4-bit binary
        let digit_value = digit.to_digit(10).unwrap();
        write!(acc, "{digit_value:04b}").unwrap();
        acc
    });

    format!("0b{bcd}")
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_zero() {
        assert_eq!(binary_coded_decimal(0), "0b0000");
    }

    #[test]
    fn test_single_digit() {
        assert_eq!(binary_coded_decimal(1), "0b0001");
        assert_eq!(binary_coded_decimal(2), "0b0010");
        assert_eq!(binary_coded_decimal(3), "0b0011");
        assert_eq!(binary_coded_decimal(4), "0b0100");
        assert_eq!(binary_coded_decimal(5), "0b0101");
        assert_eq!(binary_coded_decimal(6), "0b0110");
        assert_eq!(binary_coded_decimal(7), "0b0111");
        assert_eq!(binary_coded_decimal(8), "0b1000");
        assert_eq!(binary_coded_decimal(9), "0b1001");
    }

    #[test]
    fn test_two_digits() {
        assert_eq!(binary_coded_decimal(10), "0b00010000");
        assert_eq!(binary_coded_decimal(12), "0b00010010");
        assert_eq!(binary_coded_decimal(25), "0b00100101");
        assert_eq!(binary_coded_decimal(99), "0b10011001");
    }

    #[test]
    fn test_three_digits() {
        assert_eq!(binary_coded_decimal(100), "0b000100000000");
        assert_eq!(binary_coded_decimal(123), "0b000100100011");
        assert_eq!(binary_coded_decimal(456), "0b010001010110");
        assert_eq!(binary_coded_decimal(987), "0b100110000111");
    }

    #[test]
    fn test_large_numbers() {
        assert_eq!(binary_coded_decimal(1234), "0b0001001000110100");
        assert_eq!(binary_coded_decimal(9999), "0b1001100110011001");
    }

    #[test]
    fn test_negative_numbers() {
        // Negative numbers should be treated as 0
        assert_eq!(binary_coded_decimal(-1), "0b0000");
        assert_eq!(binary_coded_decimal(-2), "0b0000");
        assert_eq!(binary_coded_decimal(-100), "0b0000");
    }

    #[test]
    fn test_each_digit_encoding() {
        // Verify that each digit is encoded correctly in a multi-digit number
        // 67 should be: 6 (0110) and 7 (0111)
        assert_eq!(binary_coded_decimal(67), "0b01100111");

        // 305 should be: 3 (0011), 0 (0000), 5 (0101)
        assert_eq!(binary_coded_decimal(305), "0b001100000101");
    }
}


================================================
FILE: src/bit_manipulation/binary_count_trailing_zeros.rs
================================================
/// Counts the number of trailing zeros in the binary representation of a number
///
/// # Arguments
///
/// * `num` - The input number
///
/// # Returns
///
/// The number of trailing zeros in the binary representation
///
/// # Examples
///
/// ```
/// use the_algorithms_rust::bit_manipulation::binary_count_trailing_zeros;
///
/// assert_eq!(binary_count_trailing_zeros(25), 0);
/// assert_eq!(binary_count_trailing_zeros(36), 2);
/// assert_eq!(binary_count_trailing_zeros(16), 4);
/// assert_eq!(binary_count_trailing_zeros(58), 1);
/// ```
pub fn binary_count_trailing_zeros(num: u64) -> u32 {
    if num == 0 {
        return 0;
    }
    num.trailing_zeros()
}

/// Alternative implementation using bit manipulation
///
/// Uses the bit manipulation trick: log2(num & -num)
///
/// # Examples
///
/// ```
/// // This function uses bit manipulation: log2(num & -num)
/// // where num & -num isolates the rightmost set bit
/// # fn binary_count_trailing_zeros_bitwise(num: u64) -> u32 {
/// #     if num == 0 { return 0; }
/// #     let rightmost_set_bit = num & (num.wrapping_neg());
/// #     63 - rightmost_set_bit.leading_zeros()
/// # }
/// assert_eq!(binary_count_trailing_zeros_bitwise(25), 0);
/// assert_eq!(binary_count_trailing_zeros_bitwise(36), 2);
/// assert_eq!(binary_count_trailing_zeros_bitwise(16), 4);
/// ```
#[allow(dead_code)]
pub fn binary_count_trailing_zeros_bitwise(num: u64) -> u32 {
    if num == 0 {
        return 0;
    }

    let rightmost_set_bit = num & (num.wrapping_neg());
    63 - rightmost_set_bit.leading_zeros()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_basic_cases() {
        assert_eq!(binary_count_trailing_zeros(25), 0);
        assert_eq!(binary_count_trailing_zeros(36), 2);
        assert_eq!(binary_count_trailing_zeros(16), 4);
        assert_eq!(binary_count_trailing_zeros(58), 1);
        assert_eq!(binary_count_trailing_zeros(4294967296), 32);
    }

    #[test]
    fn test_zero() {
        assert_eq!(binary_count_trailing_zeros(0), 0);
    }

    #[test]
    fn test_powers_of_two() {
        assert_eq!(binary_count_trailing_zeros(1), 0);
        assert_eq!(binary_count_trailing_zeros(2), 1);
        assert_eq!(binary_count_trailing_zeros(4), 2);
        assert_eq!(binary_count_trailing_zeros(8), 3);
        assert_eq!(binary_count_trailing_zeros(1024), 10);
    }

    #[test]
    fn test_bitwise_vs_builtin() {
        // Test that bitwise implementation matches built-in trailing_zeros()
        let test_cases = vec![
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            16,
            25,
            36,
            58,
            64,
            100,
            128,
            256,
            512,
            1024,
            4294967296,
            u64::MAX - 1,
            u64::MAX,
        ];

        for num in test_cases {
            assert_eq!(
                binary_count_trailing_zeros(num),
                binary_count_trailing_zeros_bitwise(num),
                "Mismatch for input: {num}"
            );
        }
    }
}


================================================
FILE: src/bit_manipulation/binary_shifts.rs
================================================
//! Binary Shift Operations
//!
//! This module provides implementations of various binary shift operations with
//! binary string output for visualization.
//!
//! # Shift Types
//!
//! - **Logical Left Shift**: Shifts bits left, filling with zeros on the right
//! - **Logical Right Shift**: Shifts bits right, filling with zeros on the left
//! - **Arithmetic Left Shift**: Same as logical left shift (included for completeness)
//! - **Arithmetic Right Shift**: Shifts bits right, preserving the sign bit
//!
//! # Note on Arithmetic vs Logical Left Shifts
//!
//! In most systems, arithmetic left shift and logical left shift are identical operations.
//! Both shift bits to the left and fill with zeros on the right. The distinction between
//! arithmetic and logical shifts only matters for right shifts, where arithmetic shifts
//! preserve the sign bit.
//!
//! # References
//!
//! - [Bitwise Operations - Python Docs](https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types)
//! - [Bit Shift - Interview Cake](https://www.interviewcake.com/concept/java/bit-shift)

/// Performs a logical left shift on a number and returns the binary representation.
///
/// Shifts the bits of `number` to the left by `shift_amount` positions,
/// filling the rightmost bits with zeros.
///
/// # Arguments
///
/// * `number` - The non-negative integer to be shifted
/// * `shift_amount` - The number of positions to shift (must be non-negative)
///
/// # Returns
///
/// `Ok(String)` with the binary representation (including "0b" prefix),
/// or `Err(String)` if either input is negative
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::logical_left_shift;
///
/// assert_eq!(logical_left_shift(0, 1).unwrap(), "0b00");
/// assert_eq!(logical_left_shift(1, 1).unwrap(), "0b10");
/// assert_eq!(logical_left_shift(1, 5).unwrap(), "0b100000");
/// assert_eq!(logical_left_shift(17, 2).unwrap(), "0b1000100");
/// assert_eq!(logical_left_shift(1983, 4).unwrap(), "0b111101111110000");
///
/// // Negative inputs return error
/// assert!(logical_left_shift(1, -1).is_err());
/// ```
pub fn logical_left_shift(number: i32, shift_amount: i32) -> Result<String, String> {
    if number < 0 || shift_amount < 0 {
        return Err("both inputs must be positive integers".to_string());
    }

    // Get binary representation and append zeros
    let binary = format!("{number:b}");
    let zeros = "0".repeat(shift_amount as usize);
    Ok(format!("0b{binary}{zeros}"))
}

/// Performs a logical right shift on a number and returns the binary representation.
///
/// Shifts the bits of `number` to the right by `shift_amount` positions,
/// filling the leftmost bits with zeros. This is an unsigned shift operation.
///
/// # Arguments
///
/// * `number` - The non-negative integer to be shifted
/// * `shift_amount` - The number of positions to shift (must be non-negative)
///
/// # Returns
///
/// `Ok(String)` with the binary representation (including "0b" prefix),
/// or `Err(String)` if either input is negative
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::logical_right_shift;
///
/// assert_eq!(logical_right_shift(0, 1).unwrap(), "0b0");
/// assert_eq!(logical_right_shift(1, 1).unwrap(), "0b0");
/// assert_eq!(logical_right_shift(1, 5).unwrap(), "0b0");
/// assert_eq!(logical_right_shift(17, 2).unwrap(), "0b100");
/// assert_eq!(logical_right_shift(1983, 4).unwrap(), "0b1111011");
///
/// // Negative inputs return error
/// assert!(logical_right_shift(1, -1).is_err());
/// ```
pub fn logical_right_shift(number: i32, shift_amount: i32) -> Result<String, String> {
    if number < 0 || shift_amount < 0 {
        return Err("both inputs must be positive integers".to_string());
    }

    let shifted = (number as u32) >> shift_amount;
    Ok(format!("0b{shifted:b}"))
}

/// Performs an arithmetic right shift on a number and returns the binary representation.
///
/// Shifts the bits of `number` to the right by `shift_amount` positions,
/// preserving the sign bit. For positive numbers, fills with 0s; for negative
/// numbers, fills with 1s (sign extension).
///
/// # Arguments
///
/// * `number` - The integer to be shifted (can be negative)
/// * `shift_amount` - The number of positions to shift (must be non-negative)
///
/// # Returns
///
/// `Ok(String)` with the binary representation including sign bit (with "0b" prefix),
/// or `Err(String)` if shift_amount is negative
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::arithmetic_right_shift;
///
/// assert_eq!(arithmetic_right_shift(0, 1).unwrap(), "0b00");
/// assert_eq!(arithmetic_right_shift(1, 1).unwrap(), "0b00");
/// assert_eq!(arithmetic_right_shift(-1, 1).unwrap(), "0b11");
/// assert_eq!(arithmetic_right_shift(17, 2).unwrap(), "0b000100");
/// assert_eq!(arithmetic_right_shift(-17, 2).unwrap(), "0b111011");
/// assert_eq!(arithmetic_right_shift(-1983, 4).unwrap(), "0b111110000100");
/// ```
pub fn arithmetic_right_shift(number: i32, shift_amount: i32) -> Result<String, String> {
    if shift_amount < 0 {
        return Err("shift amount must be a positive integer".to_string());
    }

    let shift_amount_usize = shift_amount as usize;

    let binary_number = if number >= 0 {
        // Python: binary_number = "0" + str(bin(number)).strip("-")[2:]
        let bin_str = format!("{number:b}");
        format!("0{bin_str}")
    } else {
        // Python: binary_number_length = len(bin(number)[3:])
        // bin(-17) = "-0b10001", [3:] = "10001", length = 5
        let abs_bin = format!("{:b}", number.abs());
        let binary_number_length = abs_bin.len();

        // Python: binary_number = bin(abs(number) - (1 << binary_number_length))[3:]
        let abs_num = number.abs();
        let subtracted = abs_num - (1 << binary_number_length);

        // bin() of negative number is "-0b..." so [3:] skips "-0b"
        let bin_result = if subtracted < 0 {
            // For negative result, we need its absolute value binary representation
            // In Python, bin(-15) = "-0b1111", and [3:] = "1111"
            format!("{:b}", subtracted.abs())
        } else {
            format!("{subtracted:b}")
        };

        // Python: binary_number = "1" + "0" * (binary_number_length - len(binary_number)) + binary_number
        let padding = if binary_number_length > bin_result.len() {
            "0".repeat(binary_number_length - bin_result.len())
        } else {
            String::new()
        };

        format!("1{padding}{bin_result}")
    };

    // Python: if shift_amount >= len(binary_number):
    //             return "0b" + binary_number[0] * len(binary_number)
    if shift_amount_usize >= binary_number.len() {
        let sign_char = binary_number.chars().next().unwrap();
        return Ok(format!(
            "0b{}",
            sign_char.to_string().repeat(binary_number.len())
        ));
    }

    // Python: return ("0b" + binary_number[0] * shift_amount +
    //                 binary_number[: len(binary_number) - shift_amount])
    let sign_char = binary_number.chars().next().unwrap();
    let end_idx = binary_number.len() - shift_amount_usize;
    let slice = &binary_number[..end_idx];

    Ok(format!(
        "0b{}{}",
        sign_char.to_string().repeat(shift_amount_usize),
        slice
    ))
}

/// Performs an arithmetic left shift on a number and returns the binary representation.
///
/// **Note**: Arithmetic left shift is identical to logical left shift - both shift bits
/// to the left and fill with zeros on the right. This function is provided for
/// completeness and educational purposes. The distinction between arithmetic and logical
/// shifts only matters for right shifts (sign preservation).
///
/// # Arguments
///
/// * `number` - The integer to be shifted (can be negative)
/// * `shift_amount` - The number of positions to shift (must be non-negative)
///
/// # Returns
///
/// `Ok(String)` with the binary representation (with "0b" prefix),
/// or `Err(String)` if shift_amount is negative
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::arithmetic_left_shift;
///
/// assert_eq!(arithmetic_left_shift(1, 5).unwrap(), "0b100000");
/// assert_eq!(arithmetic_left_shift(17, 2).unwrap(), "0b1000100");
/// assert_eq!(arithmetic_left_shift(-1, 2).unwrap(), "0b11111111111111111111111111111100");
/// ```
pub fn arithmetic_left_shift(number: i32, shift_amount: i32) -> Result<String, String> {
    if shift_amount < 0 {
        return Err("shift amount must be a positive integer".to_string());
    }

    // Arithmetic left shift is the same as logical left shift
    // Both shift left and fill with zeros
    let shifted = (number << shift_amount) as u32;
    let binary = format!("{shifted:b}");
    Ok(format!("0b{binary}"))
}

#[cfg(test)]
mod tests {
    use super::*;

    // Logical Left Shift Tests
    #[test]
    fn test_logical_left_shift_zero() {
        assert_eq!(logical_left_shift(0, 1).unwrap(), "0b00");
    }

    #[test]
    fn test_logical_left_shift_one() {
        assert_eq!(logical_left_shift(1, 1).unwrap(), "0b10");
    }

    #[test]
    fn test_logical_left_shift_large_shift() {
        assert_eq!(logical_left_shift(1, 5).unwrap(), "0b100000");
    }

    #[test]
    fn test_logical_left_shift_seventeen() {
        assert_eq!(logical_left_shift(17, 2).unwrap(), "0b1000100");
    }

    #[test]
    fn test_logical_left_shift_large_number() {
        assert_eq!(logical_left_shift(1983, 4).unwrap(), "0b111101111110000");
    }

    #[test]
    fn test_logical_left_shift_negative_number() {
        assert!(logical_left_shift(-1, 1).is_err());
    }

    #[test]
    fn test_logical_left_shift_negative_shift() {
        assert!(logical_left_shift(1, -1).is_err());
    }

    #[test]
    fn test_logical_left_shift_both_negative() {
        assert!(logical_left_shift(-1, -1).is_err());
    }

    // Logical Right Shift Tests
    #[test]
    fn test_logical_right_shift_zero() {
        assert_eq!(logical_right_shift(0, 1).unwrap(), "0b0");
    }

    #[test]
    fn test_logical_right_shift_one() {
        assert_eq!(logical_right_shift(1, 1).unwrap(), "0b0");
    }

    #[test]
    fn test_logical_right_shift_shift_all_bits() {
        assert_eq!(logical_right_shift(1, 5).unwrap(), "0b0");
    }

    #[test]
    fn test_logical_right_shift_seventeen() {
        assert_eq!(logical_right_shift(17, 2).unwrap(), "0b100");
    }

    #[test]
    fn test_logical_right_shift_large_number() {
        assert_eq!(logical_right_shift(1983, 4).unwrap(), "0b1111011");
    }

    #[test]
    fn test_logical_right_shift_negative_number() {
        assert!(logical_right_shift(-1, 1).is_err());
    }

    #[test]
    fn test_logical_right_shift_negative_shift() {
        assert!(logical_right_shift(1, -1).is_err());
    }

    #[test]
    fn test_logical_right_shift_both_negative() {
        assert!(logical_right_shift(-1, -1).is_err());
    }

    // Arithmetic Right Shift Tests
    #[test]
    fn test_arithmetic_right_shift_zero() {
        assert_eq!(arithmetic_right_shift(0, 1).unwrap(), "0b00");
    }

    #[test]
    fn test_arithmetic_right_shift_one() {
        assert_eq!(arithmetic_right_shift(1, 1).unwrap(), "0b00");
    }

    #[test]
    fn test_arithmetic_right_shift_negative_one() {
        assert_eq!(arithmetic_right_shift(-1, 1).unwrap(), "0b11");
    }

    #[test]
    fn test_arithmetic_right_shift_seventeen_positive() {
        assert_eq!(arithmetic_right_shift(17, 2).unwrap(), "0b000100");
    }

    #[test]
    fn test_arithmetic_right_shift_seventeen_negative() {
        assert_eq!(arithmetic_right_shift(-17, 2).unwrap(), "0b111011");
    }

    #[test]
    fn test_arithmetic_right_shift_large_negative() {
        assert_eq!(arithmetic_right_shift(-1983, 4).unwrap(), "0b111110000100");
    }

    #[test]
    fn test_arithmetic_right_shift_negative_shift() {
        assert!(arithmetic_right_shift(1, -1).is_err());
    }

    #[test]
    fn test_arithmetic_right_shift_preserves_sign_positive() {
        // Positive number should have leading 0
        // 16 = 0b10000, with sign bit = 0b010000, shift right by 2 = 0b000100
        let result = arithmetic_right_shift(16, 2).unwrap();
        assert!(result.starts_with("0b0"));
        assert_eq!(result, "0b000100");
    }

    #[test]
    fn test_arithmetic_right_shift_preserves_sign_negative() {
        // Negative number should have leading 1
        let result = arithmetic_right_shift(-16, 2).unwrap();
        assert!(result.starts_with("0b1"));
    }

    #[test]
    fn test_arithmetic_right_shift_large_shift_positive() {
        // Shifting positive number by large amount
        // 1 = 0b1, with sign bit = 0b01 (2 bits)
        // Shift by 10 (>= 2), so return sign bit repeated 2 times = 0b00
        assert_eq!(arithmetic_right_shift(1, 10).unwrap(), "0b00");
    }

    #[test]
    fn test_arithmetic_right_shift_large_shift_negative() {
        // Shifting negative number by large amount should preserve sign
        // -1 has all 1s, minimal representation with sign bit
        let result = arithmetic_right_shift(-1, 10).unwrap();
        assert!(result.starts_with("0b1"));
        // All bits should be 1s (sign extended)
        assert!(result.chars().skip(2).all(|c| c == '1'));
    }

    // Arithmetic Left Shift Tests
    #[test]
    fn test_arithmetic_left_shift_basic() {
        assert_eq!(arithmetic_left_shift(1, 5).unwrap(), "0b100000");
        assert_eq!(arithmetic_left_shift(17, 2).unwrap(), "0b1000100");
    }

    #[test]
    fn test_arithmetic_left_shift_negative() {
        // Negative numbers in arithmetic left shift
        // -1 << 2 in two's complement
        let result = arithmetic_left_shift(-1, 2).unwrap();
        assert!(result.starts_with("0b"));
        // Should contain all 1s followed by 00
        assert!(result.ends_with("00"));
    }

    #[test]
    fn test_arithmetic_left_shift_zero() {
        assert_eq!(arithmetic_left_shift(0, 3).unwrap(), "0b0");
    }

    #[test]
    fn test_arithmetic_left_shift_negative_shift() {
        assert!(arithmetic_left_shift(1, -1).is_err());
    }

    #[test]
    fn test_arithmetic_left_shift_same_as_logical() {
        // For positive numbers, arithmetic and logical left shifts are identical
        let num = 17;
        let shift = 3;
        let arithmetic = arithmetic_left_shift(num, shift).unwrap();
        let logical = logical_left_shift(num, shift).unwrap();

        // Parse the binary strings and compare the values
        let arith_val = u32::from_str_radix(&arithmetic[2..], 2).unwrap();
        let logic_val = u32::from_str_radix(&logical[2..], 2).unwrap();
        assert_eq!(arith_val, logic_val);
    }

    #[test]
    fn test_all_shifts_on_same_value() {
        let number = 8;
        let shift = 2;

        // 8 (0b1000) << 2 = 32 (0b100000)
        assert_eq!(logical_left_shift(number, shift).unwrap(), "0b100000");
        assert_eq!(arithmetic_left_shift(number, shift).unwrap(), "0b100000");

        // 8 (0b1000) >> 2 = 2 (0b10)
        assert_eq!(logical_right_shift(number, shift).unwrap(), "0b10");

        // 8 (0b1000) >> 2 = 2 (0b010)
        assert_eq!(arithmetic_right_shift(number, shift).unwrap(), "0b00010");
    }
}


================================================
FILE: src/bit_manipulation/counting_bits.rs
================================================
//! This module implements a function to count the number of set bits (1s)
//! in the binary representation of an unsigned integer.
//! It uses Brian Kernighan's algorithm, which efficiently clears the least significant
//! set bit in each iteration until all bits are cleared.
//! The algorithm runs in O(k), where k is the number of set bits.

/// Counts the number of set bits in an unsigned integer.
///
/// # Arguments
///
/// * `n` - An unsigned 32-bit integer whose set bits will be counted.
///
/// # Returns
///
/// * `usize` - The number of set bits (1s) in the binary representation of the input number.
pub fn count_set_bits(mut n: usize) -> usize {
    // Initialize a variable to keep track of the count of set bits
    let mut count = 0;
    while n > 0 {
        // Clear the least significant set bit by
        // performing a bitwise AND operation with (n - 1)
        n &= n - 1;

        // Increment the count for each set bit found
        count += 1;
    }

    count
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_count_set_bits {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (input, expected) = $test_case;
                    assert_eq!(count_set_bits(input), expected);
                }
            )*
        };
    }
    test_count_set_bits! {
        test_count_set_bits_zero: (0, 0),
        test_count_set_bits_one: (1, 1),
        test_count_set_bits_power_of_two: (16, 1),
        test_count_set_bits_all_set_bits: (usize::MAX, std::mem::size_of::<usize>() * 8),
        test_count_set_bits_alternating_bits: (0b10101010, 4),
        test_count_set_bits_mixed_bits: (0b11011011, 6),
    }
}


================================================
FILE: src/bit_manipulation/find_missing_number.rs
================================================
/// Finds the missing number in a slice of consecutive integers.
///
/// This function uses XOR bitwise operation to find the missing number.
/// It XORs all expected numbers in the range [min, max] with the actual
/// numbers present in the array. Since XOR has the property that `a ^ a = 0`,
/// all present numbers cancel out, leaving only the missing number.
///
/// # Arguments
///
/// * `nums` - A slice of integers forming a sequence with one missing number
///
/// # Returns
///
/// * `Ok(i32)` - The missing number in the sequence
/// * `Err(String)` - An error message if the input is invalid
///
/// # Examples
///
/// ```
/// # use the_algorithms_rust::bit_manipulation::find_missing_number;
/// assert_eq!(find_missing_number(&[0, 1, 3, 4]).unwrap(), 2);
/// assert_eq!(find_missing_number(&[4, 3, 1, 0]).unwrap(), 2);
/// assert_eq!(find_missing_number(&[-4, -3, -1, 0]).unwrap(), -2);
/// assert_eq!(find_missing_number(&[-2, 2, 1, 3, 0]).unwrap(), -1);
/// assert_eq!(find_missing_number(&[1, 3, 4, 5, 6]).unwrap(), 2);
/// ```
pub fn find_missing_number(nums: &[i32]) -> Result<i32, String> {
    if nums.is_empty() {
        return Err("input array must not be empty".to_string());
    }

    if nums.len() == 1 {
        return Err("array must have at least 2 elements to find a missing number".to_string());
    }

    let low = *nums.iter().min().unwrap();
    let high = *nums.iter().max().unwrap();

    let mut missing_number = high;

    for i in low..high {
        let index = (i - low) as usize;
        missing_number ^= i ^ nums[index];
    }

    Ok(missing_number)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_missing_in_middle() {
        assert_eq!(find_missing_number(&[0, 1, 3, 4]).unwrap(), 2);
    }

    #[test]
    fn test_unordered_array() {
        assert_eq!(find_missing_number(&[4, 3, 1, 0]).unwrap(), 2);
    }

    #[test]
    fn test_negative_numbers() {
        assert_eq!(find_missing_number(&[-4, -3, -1, 0]).unwrap(), -2);
    }

    #[test]
    fn test_negative_and_positive() {
        assert_eq!(find_missing_number(&[-2, 2, 1, 3, 0]).unwrap(), -1);
    }

    #[test]
    fn test_missing_at_start() {
        assert_eq!(find_missing_number(&[1, 3, 4, 5, 6]).unwrap(), 2);
    }

    #[test]
    fn test_unordered_missing_middle() {
        assert_eq!(find_missing_number(&[6, 5, 4, 2, 1]).unwrap(), 3);
    }

    #[test]
    fn test_another_unordered() {
        assert_eq!(find_missing_number(&[6, 1, 5, 3, 4]).unwrap(), 2);
    }

    #[test]
    fn test_empty_array() {
        assert!(find_missing_number(&[]).is_err());
        assert_eq!(
            find_missing_number(&[]).unwrap_err(),
            "input array must not be empty"
        );
    }

    #[test]
    fn test_single_element() {
        assert!(find_missing_number(&[5]).is_err());
        assert_eq!(
            find_missing_number(&[5]).unwrap_err(),
            "array must have at least 2 elements to find a missing number"
        );
    }

    #[test]
    fn test_two_elements() {
        assert_eq!(find_missing_number(&[0, 2]).unwrap(), 1);
        assert_eq!(find_missing_number(&[2, 0]).unwrap(), 1);
    }

    #[test]
    fn test_large_range() {
        assert_eq!(find_missing_number(&[100, 101, 103, 104]).unwrap(), 102);
    }

    #[test]
    fn test_missing_at_boundaries() {
        // Missing is the second to last element
        assert_eq!(find_missing_number(&[1, 2, 3, 5]).unwrap(), 4);
    }
}


================================================
FILE: src/bit_manipulation/find_previous_power_of_two.rs
================================================
//! Previous Power of Two
//!
//! This module provides a function to find the largest power of two that is less than
//! or equal to a given non-negative integer.
//!
//! # Algorithm
//!
//! The algorithm works by repeatedly left-shifting (doubling) a power value starting
//! from 1 until it exceeds the input number, then returning the previous power (by
//! right-shifting once).
//!
//! For more information: <https://stackoverflow.com/questions/1322510>

/// Finds the largest power of two that is less than or equal to a given integer.
///
/// The function uses bit shifting to efficiently find the power of two. It starts
/// with 1 and keeps doubling (left shift) until it exceeds the input, then returns
/// the previous value (right shift).
///
/// # Arguments
///
/// * `number` - A non-negative integer
///
/// # Returns
///
/// A `Result` containing:
/// - `Ok(u32)` - The largest power of two ≤ the input number
/// - `Err(String)` - An error message if the input is negative
///
/// # Examples
///
/// ```
/// use the_algorithms_rust::bit_manipulation::find_previous_power_of_two;
///
/// assert_eq!(find_previous_power_of_two(0).unwrap(), 0);
/// assert_eq!(find_previous_power_of_two(1).unwrap(), 1);
/// assert_eq!(find_previous_power_of_two(2).unwrap(), 2);
/// assert_eq!(find_previous_power_of_two(3).unwrap(), 2);
/// assert_eq!(find_previous_power_of_two(4).unwrap(), 4);
/// assert_eq!(find_previous_power_of_two(5).unwrap(), 4);
/// assert_eq!(find_previous_power_of_two(8).unwrap(), 8);
/// assert_eq!(find_previous_power_of_two(15).unwrap(), 8);
/// assert_eq!(find_previous_power_of_two(16).unwrap(), 16);
/// assert_eq!(find_previous_power_of_two(17).unwrap(), 16);
///
/// // Negative numbers return an error
/// assert!(find_previous_power_of_two(-5).is_err());
/// ```
///
/// # Errors
///
/// Returns an error if the input number is negative.
pub fn find_previous_power_of_two(number: i32) -> Result<u32, String> {
    if number < 0 {
        return Err("Input must be a non-negative integer".to_string());
    }

    let number = number as u32;

    if number == 0 {
        return Ok(0);
    }

    let mut power = 1u32;
    while power <= number {
        power <<= 1; // Equivalent to multiplying by 2
    }

    Ok(if number > 1 { power >> 1 } else { 1 })
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_zero() {
        assert_eq!(find_previous_power_of_two(0).unwrap(), 0);
    }

    #[test]
    fn test_one() {
        assert_eq!(find_previous_power_of_two(1).unwrap(), 1);
    }

    #[test]
    fn test_powers_of_two() {
        assert_eq!(find_previous_power_of_two(2).unwrap(), 2);
        assert_eq!(find_previous_power_of_two(4).unwrap(), 4);
        assert_eq!(find_previous_power_of_two(8).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(16).unwrap(), 16);
        assert_eq!(find_previous_power_of_two(32).unwrap(), 32);
        assert_eq!(find_previous_power_of_two(64).unwrap(), 64);
        assert_eq!(find_previous_power_of_two(128).unwrap(), 128);
        assert_eq!(find_previous_power_of_two(256).unwrap(), 256);
        assert_eq!(find_previous_power_of_two(512).unwrap(), 512);
        assert_eq!(find_previous_power_of_two(1024).unwrap(), 1024);
    }

    #[test]
    fn test_numbers_between_powers() {
        // Between 2 and 4
        assert_eq!(find_previous_power_of_two(3).unwrap(), 2);

        // Between 4 and 8
        assert_eq!(find_previous_power_of_two(5).unwrap(), 4);
        assert_eq!(find_previous_power_of_two(6).unwrap(), 4);
        assert_eq!(find_previous_power_of_two(7).unwrap(), 4);

        // Between 8 and 16
        assert_eq!(find_previous_power_of_two(9).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(10).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(11).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(12).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(13).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(14).unwrap(), 8);
        assert_eq!(find_previous_power_of_two(15).unwrap(), 8);

        // Between 16 and 32
        assert_eq!(find_previous_power_of_two(17).unwrap(), 16);
        assert_eq!(find_previous_power_of_two(20).unwrap(), 16);
        assert_eq!(find_previous_power_of_two(31).unwrap(), 16);
    }

    #[test]
    fn test_range_0_to_17() {
        // Test the exact output from the Python docstring
        let expected = vec![0, 1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16];
        let results: Vec<u32> = (0..18)
            .map(|i| find_previous_power_of_two(i).unwrap())
            .collect();
        assert_eq!(results, expected);
    }

    #[test]
    fn test_large_numbers() {
        assert_eq!(find_previous_power_of_two(100).unwrap(), 64);
        assert_eq!(find_previous_power_of_two(500).unwrap(), 256);
        assert_eq!(find_previous_power_of_two(1000).unwrap(), 512);
        assert_eq!(find_previous_power_of_two(2000).unwrap(), 1024);
        assert_eq!(find_previous_power_of_two(10000).unwrap(), 8192);
    }

    #[test]
    fn test_max_safe_values() {
        assert_eq!(find_previous_power_of_two(1023).unwrap(), 512);
        assert_eq!(find_previous_power_of_two(2047).unwrap(), 1024);
        assert_eq!(find_previous_power_of_two(4095).unwrap(), 2048);
    }

    #[test]
    fn test_negative_number_returns_error() {
        let result = find_previous_power_of_two(-1);
        assert!(result.is_err());
        assert_eq!(result.unwrap_err(), "Input must be a non-negative integer");
    }

    #[test]
    fn test_negative_numbers_return_errors() {
        assert!(find_previous_power_of_two(-5).is_err());
        assert!(find_previous_power_of_two(-10).is_err());
        assert!(find_previous_power_of_two(-100).is_err());
    }

    #[test]
    fn test_edge_cases() {
        // One less than powers of two
        assert_eq!(find_previous_power_of_two(127).unwrap(), 64);
        assert_eq!(find_previous_power_of_two(255).unwrap(), 128);
        assert_eq!(find_previous_power_of_two(511).unwrap(), 256);
    }
}


================================================
FILE: src/bit_manipulation/find_unique_number.rs
================================================
/// Finds the unique number in a slice where every other element appears twice.
///
/// This function uses the XOR bitwise operation. Since XOR has the property that
/// `a ^ a = 0` and `a ^ 0 = a`, all paired numbers cancel out, leaving only the
/// unique number.
///
/// # Arguments
///
/// * `arr` - A slice of integers where all elements except one appear exactly twice
///
/// # Returns
///
/// * `Ok(i32)` - The unique number that appears only once
/// * `Err(String)` - An error message if the input is empty
///
/// # Examples
///
/// ```
/// # use the_algorithms_rust::bit_manipulation::find_unique_number;
/// assert_eq!(find_unique_number(&[1, 1, 2, 2, 3]).unwrap(), 3);
/// assert_eq!(find_unique_number(&[4, 5, 4, 6, 6]).unwrap(), 5);
/// assert_eq!(find_unique_number(&[7]).unwrap(), 7);
/// assert_eq!(find_unique_number(&[10, 20, 10]).unwrap(), 20);
/// assert!(find_unique_number(&[]).is_err());
/// ```
pub fn find_unique_number(arr: &[i32]) -> Result<i32, String> {
    if arr.is_empty() {
        return Err("input list must not be empty".to_string());
    }

    let result = arr.iter().fold(0, |acc, &num| acc ^ num);
    Ok(result)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_basic_case() {
        assert_eq!(find_unique_number(&[1, 1, 2, 2, 3]).unwrap(), 3);
    }

    #[test]
    fn test_different_order() {
        assert_eq!(find_unique_number(&[4, 5, 4, 6, 6]).unwrap(), 5);
    }

    #[test]
    fn test_single_element() {
        assert_eq!(find_unique_number(&[7]).unwrap(), 7);
    }

    #[test]
    fn test_three_elements() {
        assert_eq!(find_unique_number(&[10, 20, 10]).unwrap(), 20);
    }

    #[test]
    fn test_empty_array() {
        assert!(find_unique_number(&[]).is_err());
        assert_eq!(
            find_unique_number(&[]).unwrap_err(),
            "input list must not be empty"
        );
    }

    #[test]
    fn test_negative_numbers() {
        assert_eq!(find_unique_number(&[-1, -1, -2, -2, -3]).unwrap(), -3);
    }

    #[test]
    fn test_large_numbers() {
        assert_eq!(
            find_unique_number(&[1000, 2000, 1000, 3000, 3000]).unwrap(),
            2000
        );
    }

    #[test]
    fn test_zero() {
        assert_eq!(find_unique_number(&[0, 1, 1]).unwrap(), 0);
    }
}


================================================
FILE: src/bit_manipulation/hamming_distance.rs
================================================
//! Hamming Distance
//!
//! This module implements the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance)
//! algorithm for both integers and strings.
//!
//! The Hamming distance between two values is the number of positions at which
//! the corresponding symbols differ.

/// Counts the number of set bits (1s) in a 64-bit unsigned integer.
///
/// # Arguments
///
/// * `value` - The number to count set bits in
///
/// # Returns
///
/// The number of set bits in the value
///
/// # Example
///
/// ```
/// // This is a private helper function
/// let value: u64 = 11; // 1011 in binary has 3 set bits
/// ```
fn bit_count(mut value: u64) -> u64 {
    let mut count = 0;
    while value != 0 {
        if value & 1 == 1 {
            count += 1;
        }
        value >>= 1;
    }
    count
}

/// Calculates the Hamming distance between two unsigned 64-bit integers.
///
/// The Hamming distance is the number of bit positions at which the
/// corresponding bits differ. This is computed by taking the XOR of the
/// two numbers and counting the set bits.
///
/// # Arguments
///
/// * `a` - The first integer
/// * `b` - The second integer
///
/// # Returns
///
/// The number of differing bits between `a` and `b`
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::hamming_distance;
///
/// let distance = hamming_distance(11, 2);
/// assert_eq!(distance, 2);
/// ```
pub fn hamming_distance(a: u64, b: u64) -> u64 {
    bit_count(a ^ b)
}

/// Calculates the Hamming distance between two strings of equal length.
///
/// The Hamming distance is the number of positions at which the
/// corresponding characters differ.
///
/// # Arguments
///
/// * `a` - The first string
/// * `b` - The second string
///
/// # Returns
///
/// The number of differing characters between `a` and `b`
///
/// # Panics
///
/// Panics if the strings have different lengths
///
/// # Example
///
/// ```
/// use the_algorithms_rust::bit_manipulation::hamming_distance_str;
///
/// let distance = hamming_distance_str("1101", "1111");
/// assert_eq!(distance, 1);
/// ```
pub fn hamming_distance_str(a: &str, b: &str) -> u64 {
    assert_eq!(
        a.len(),
        b.len(),
        "Strings must have the same length for Hamming distance calculation"
    );

    a.chars()
        .zip(b.chars())
        .filter(|(ch_a, ch_b)| ch_a != ch_b)
        .count() as u64
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_bit_count() {
        assert_eq!(bit_count(0), 0);
        assert_eq!(bit_count(11), 3); // 1011 in binary
        assert_eq!(bit_count(15), 4); // 1111 in binary
    }

    #[test]
    fn test_hamming_distance_integers() {
        assert_eq!(hamming_distance(11, 2), 2);
        assert_eq!(hamming_distance(2, 0), 1);
        assert_eq!(hamming_distance(11, 0), 3);
        assert_eq!(hamming_distance(0, 0), 0);
    }

    #[test]
    fn test_hamming_distance_strings() {
        assert_eq!(hamming_distance_str("1101", "1111"), 1);
        assert_eq!(hamming_distance_str("1111", "1111"), 0);
        assert_eq!(hamming_distance_str("0000", "1111"), 4);
        assert_eq!(hamming_distance_str("alpha", "alphb"), 1);
        assert_eq!(hamming_distance_str("abcd", "abcd"), 0);
        assert_eq!(hamming_distance_str("dcba", "abcd"), 4);
    }

    #[test]
    #[should_panic(expected = "Strings must have the same length")]
    fn test_hamming_distance_strings_different_lengths() {
        hamming_distance_str("abc", "abcd");
    }
}


================================================
FILE: src/bit_manipulation/highest_set_bit.rs
================================================
//! This module provides a function to find the position of the most significant bit (MSB)
//! set to 1 in a given positive integer.

/// Finds the position of the highest (most significant) set bit in a positive integer.
///
/// # Arguments
///
/// * `num` - An integer value for which the highest set bit will be determined.
///
/// # Returns
///
/// *  Returns `Some(position)` if a set bit exists or `None` if no bit is set.
pub fn find_highest_set_bit(num: usize) -> Option<usize> {
    if num == 0 {
        return None;
    }

    let mut position = 0;
    let mut n = num;

    while n > 0 {
        n >>= 1;
        position += 1;
    }

    Some(position - 1)
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! test_find_highest_set_bit {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (input, expected) = $test_case;
                    assert_eq!(find_highest_set_bit(input), expected);
                }
            )*
        };
    }

    test_find_highest_set_bit! {
        test_positive_number: (18, Some(4)),
        test_0: (0, None),
        test_1: (1, Some(0)),
        test_2: (2, Some(1)),
        test_3: (3, Some(1)),
    }
}


================================================
FILE: src/bit_manipulation/is_power_of_two.rs
================================================
//! Power of Two Check
//!
//! This module provides a function to determine if a given positive integer is a power of two
//! using efficient bit manipulation.
//!
//! # Algorithm
//!
//! The algorithm uses the property that powers of two have exactly one bit set in their
//! binary representation. When we subtract 1 from a power of two, all bits after the single
//! set bit become 1, and the set bit becomes 0:
//!
//! ```text
//! n     = 0..100..00  (power of 2)
//! n - 1 = 0..011..11
//! n & (n - 1) = 0     (no intersections)
//! ```
//!
//! For example:
//! - 8 in binary:  1000
//! - 7 in binary:  0111
//! - 8 & 7 = 0000 = 0 ✓
//!
//! Author: Alexander Pantyukhin
//! Date: November 1, 2022

/// Determines if a given number is a power of two.
///
/// This function uses bit manipulation to efficiently check if a number is a power of two.
/// A number is a power of two if it has exactly one bit set in its binary representation.
/// The check `number & (number - 1) == 0` leverages this property.
///
/// # Arguments
///
/// * `number` - An integer to check (must be non-negative)
///
/// # Returns
///
/// A `Result` containing:
/// - `Ok(true)` - If the number is a power of two (including 0 and 1)
/// - `Ok(false)` - If the number is not a power of two
/// - `Err(String)` - If the number is negative
///
/// # Examples
///
/// ```
/// use the_algorithms_rust::bit_manipulation::is_power_of_two;
///
/// assert_eq!(is_power_of_two(0).unwrap(), true);
/// assert_eq!(is_power_of_two(1).unwrap(), true);
/// assert_eq!(is_power_of_two(2).unwrap(), true);
/// assert_eq!(is_power_of_two(4).unwrap(), true);
/// assert_eq!(is_power_of_two(8).unwrap(), true);
/// assert_eq!(is_power_of_two(16).unwrap(), true);
///
/// assert_eq!(is_power_of_two(3).unwrap(), false);
/// assert_eq!(is_power_of_two(6).unwrap(), false);
/// assert_eq!(is_power_of_two(17).unwrap(), false);
///
/// // Negative numbers return an error
/// assert!(is_power_of_two(-1).is_err());
/// ```
///
/// # Errors
///
/// Returns an error if the input number is negative.
///
/// # Time Complexity
///
/// O(1) - The function performs a constant number of operations regardless of input size.
pub fn is_power_of_two(number: i32) -> Result<bool, String> {
    if number < 0 {
        return Err("number must not be negative".to_string());
    }

    // Convert to u32 for safe bit operations
    let num = number as u32;

    // Check if number & (number - 1) == 0
    // For powers of 2, this will always be true
    Ok(num & num.wrapping_sub(1) == 0)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_zero() {
        // 0 is considered a power of 2 by the algorithm (2^(-∞) interpretation)
        assert!(is_power_of_two(0).unwrap());
    }

    #[test]
    fn test_one() {
        // 1 = 2^0
        assert!(is_power_of_two(1).unwrap());
    }

    #[test]
    fn test_powers_of_two() {
        assert!(is_power_of_two(2).unwrap()); // 2^1
        assert!(is_power_of_two(4).unwrap()); // 2^2
        assert!(is_power_of_two(8).unwrap()); // 2^3
        assert!(is_power_of_two(16).unwrap()); // 2^4
        assert!(is_power_of_two(32).unwrap()); // 2^5
        assert!(is_power_of_two(64).unwrap()); // 2^6
        assert!(is_power_of_two(128).unwrap()); // 2^7
        assert!(is_power_of_two(256).unwrap()); // 2^8
        assert!(is_power_of_two(512).unwrap()); // 2^9
        assert!(is_power_of_two(1024).unwrap()); // 2^10
        assert!(is_power_of_two(2048).unwrap()); // 2^11
        assert!(is_power_of_two(4096).unwrap()); // 2^12
        assert!(is_power_of_two(8192).unwrap()); // 2^13
        assert!(is_power_of_two(16384).unwrap()); // 2^14
        assert!(is_power_of_two(32768).unwrap()); // 2^15
        assert!(is_power_of_two(65536).unwrap()); // 2^16
    }

    #[test]
    fn test_non_powers_of_two() {
        assert!(!is_power_of_two(3).unwrap());
        assert!(!is_power_of_two(5).unwrap());
        assert!(!is_power_of_two(6).unwrap());
        assert!(!is_power_of_two(7).unwrap());
        assert!(!is_power_of_two(9).unwrap());
        assert!(!is_power_of_two(10).unwrap());
        assert!(!is_power_of_two(11).unwrap());
        assert!(!is_power_of_two(12).unwrap());
        assert!(!is_power_of_two(13).unwrap());
        assert!(!is_power_of_two(14).unwrap());
        assert!(!is_power_of_two(15).unwrap());
        assert!(!is_power_of_two(17).unwrap());
        assert!(!is_power_of_two(18).unwrap());
    }

    #[test]
    fn test_specific_non_powers() {
        assert!(!is_power_of_two(6).unwrap());
        assert!(!is_power_of_two(17).unwrap());
        assert!(!is_power_of_two(100).unwrap());
        assert!(!is_power_of_two(1000).unwrap());
    }

    #[test]
    fn test_large_powers_of_two() {
        assert!(is_power_of_two(131072).unwrap()); // 2^17
        assert!(is_power_of_two(262144).unwrap()); // 2^18
        assert!(is_power_of_two(524288).unwrap()); // 2^19
        assert!(is_power_of_two(1048576).unwrap()); // 2^20
    }

    #[test]
    fn test_numbers_near_powers_of_two() {
        // One less than powers of 2
        assert!(!is_power_of_two(3).unwrap()); // 2^2 - 1
        assert!(!is_power_of_two(7).unwrap()); // 2^3 - 1
        assert!(!is_power_of_two(15).unwrap()); // 2^4 - 1
        assert!(!is_power_of_two(31).unwrap()); // 2^5 - 1
        assert!(!is_power_of_two(63).unwrap()); // 2^6 - 1
        assert!(!is_power_of_two(127).unwrap()); // 2^7 - 1
        assert!(!is_power_of_two(255).unwrap()); // 2^8 - 1

        // One more than powers of 2
        assert!(!is_power_of_two(3).unwrap()); // 2^1 + 1
        assert!(!is_power_of_two(5).unwrap()); // 2^2 + 1
        assert!(!is_power_of_two(9).unwrap()); // 2^3 + 1
        assert!(!is_power_of_two(17).unwrap()); // 2^4 + 1
        assert!(!is_power_of_two(33).unwrap()); // 2^5 + 1
        assert!(!is_power_of_two(65).unwrap()); // 2^6 + 1
        assert!(!is_power_of_two(129).unwrap()); // 2^7 + 1
    }

    #[test]
    fn test_negative_number_returns_error() {
        let result = is_power_of_two(-1);
        assert!(result.is_err());
        assert_eq!(result.unwrap_err(), "number must not be negative");
    }

    #[test]
    fn test_multiple_negative_numbers() {
        assert!(is_power_of_two(-1).is_err());
        assert!(is_power_of_two(-2).is_err());
        assert!(is_power_of_two(-4).is_err());
        assert!(is_power_of_two(-8).is_err());
        assert!(is_power_of_two(-100).is_err());
    }

    #[test]
    fn test_all_powers_of_two_up_to_30() {
        // Test 2^0 through 2^30
        for i in 0..=30 {
            let power = 1u32 << i; // 2^i
            assert!(
                is_power_of_two(power as i32).unwrap(),
                "2^{i} = {power} should be a power of 2"
            );
        }
    }

    #[test]
    fn test_range_verification() {
        // Test that between consecutive powers of 2, only the powers return true
        for i in 1..10 {
            let power = 1 << i; // 2^i
            assert!(is_power_of_two(power).unwrap());

            // Check numbers between this power and the next
            let next_power = 1 << (i + 1);
            for num in (power + 1)..next_power {
                assert!(
                    !is_power_of_two(num).unwrap(),
                    "{num} should not be a power of 2"
                );
            }
        }
    }

    #[test]
    fn test_bit_manipulation_correctness() {
        // Verify the bit manipulation logic for specific examples
        // For 8: 1000 & 0111 = 0000 ✓
        assert_eq!(8 & 7, 0);
        assert!(is_power_of_two(8).unwrap());

        // For 16: 10000 & 01111 = 00000 ✓
        assert_eq!(16 & 15, 0);
        assert!(is_power_of_two(16).unwrap());

        // For 6: 110 & 101 = 100 ✗
        assert_ne!(6 & 5, 0);
        assert!(!is_power_of_two(6).unwrap());
    }

    #[test]
    fn test_edge_case_max_i32_power_of_two() {
        // Largest power of 2 that fits in i32: 2^30 = 1073741824
        assert!(is_power_of_two(1073741824).unwrap());
    }
}


================================================
FILE: src/bit_manipulation/mod.rs
================================================
mod binary_coded_decimal;
mod binary_count_trailing_zeros;
mod binary_shifts;
mod counting_bits;
mod find_missing_number;
mod find_previous_power_of_two;
mod find_unique_number;
mod hamming_distance;
mod highest_set_bit;
mod is_power_of_two;
mod n_bits_gray_code;
mod reverse_bits;
mod rightmost_set_bit;
mod sum_of_two_integers;
mod swap_odd_even_bits;
mod twos_complement;

pub use self::binary_coded_decimal::binary_coded_decimal;
pub use self::binary_count_trailing_zeros::binary_count_trailing_zeros;
pub use self::binary_shifts::{
    arithmetic_left_shift, arithmetic_right_shift, logical_left_shift, logical_right_shift,
};
pub use self::counting_bits::count_set_bits;
pub use self::find_missing_number::find_missing_number;
pub use self::find_previous_power_of_two::find_previous_power_of_two;
pub use self::find_unique_number::find_unique_number;
pub use self::hamming_distance::{hamming_distance, hamming_distance_str};
pub use self::highest_set_bit::find_highest_set_bit;
pub use self::is_power_of_two::is_power_of_two;
pub use self::n_bits_gray_code::generate_gray_code;
pub use self::reverse_bits::reverse_bits;
pub use self::rightmost_set_bit::{index_of_rightmost_set_bit, index_of_rightmost_set_bit_log};
pub use self::sum_of_two_integers::add_two_integers;
pub use self::swap_odd_even_bits::swap_odd_even_bits;
pub use self::twos_complement::twos_complement;


================================================
FILE: src/bit_manipulation/n_bits_gray_code.rs
================================================
/// Custom error type for Gray code generation.
#[derive(Debug, PartialEq)]
pub enum GrayCodeError {
    ZeroBitCount,
}

/// Generates an n-bit Gray code sequence using the direct Gray code formula.
///
/// # Arguments
///
/// * `n` - The number of bits for the Gray code.
///
/// # Returns
///
/// A vector of Gray code sequences as strings.
pub fn generate_gray_code(n: usize) -> Result<Vec<String>, GrayCodeError> {
    if n == 0 {
        return Err(GrayCodeError::ZeroBitCount);
    }

    let num_codes = 1 << n;
    let mut result = Vec::with_capacity(num_codes);

    for i in 0..num_codes {
        let gray = i ^ (i >> 1);
        let gray_code = (0..n)
            .rev()
            .map(|bit| if gray & (1 << bit) != 0 { '1' } else { '0' })
            .collect::<String>();
        result.push(gray_code);
    }

    Ok(result)
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! gray_code_tests {
        ($($name:ident: $test_case:expr,)*) => {
            $(
                #[test]
                fn $name() {
                    let (input, expected) = $test_case;
                    assert_eq!(generate_gray_code(input), expected);
                }
            )*
        };
    }

    gray_code_tests! {
        zero_bit_count: (0, Err(GrayCodeError::ZeroBitCount)),
        gray_code_1_bit: (1, Ok(vec![
            "0".to_string(),
            "1".to_string(),
        ])),
        gray_code_2_bit: (2, Ok(vec![
            "00".to_string(),
            "01".to_string(),
            "11".to_string(),
            "10".to_string(),
        ])),
        gray_code_3_bit: (3, Ok(vec![
            "000".to_string(),
            "001".to_string(),
            "011".to_string(),
            "010".to_string(),
            "110".to_string(),
            "111".to_string(),
            "101".to_string(),
            "100".to_string(),
        ])),
    }
}


================================================
FILE: src/bit_manipulation/reverse_bits.rs
================================================
//! This module provides a function to reverse the bits of a 32-bit unsigned integer.
//!
//! The algorithm works by iterating through each of the 32 bits from least
//! significant to most significant, extracting each bit and pla
Download .txt
gitextract_gs1_le18/

├── .gitconfig
├── .github/
│   ├── CODEOWNERS
│   ├── dependabot.yml
│   ├── pull_request_template.md
│   └── workflows/
│       ├── build.yml
│       ├── code_ql.yml
│       ├── directory_workflow.yml
│       ├── scripts/
│       │   └── build_directory/
│       │       ├── Cargo.toml
│       │       └── src/
│       │           ├── lib.rs
│       │           └── main.rs
│       ├── stale.yml
│       └── upload_coverage_report.yml
├── .gitignore
├── .gitpod.Dockerfile
├── .gitpod.yml
├── CONTRIBUTING.md
├── Cargo.toml
├── DIRECTORY.md
├── LICENSE
├── README.md
├── clippy.toml
├── git_hooks/
│   └── pre-commit
└── src/
    ├── backtracking/
    │   ├── all_combination_of_size_k.rs
    │   ├── graph_coloring.rs
    │   ├── hamiltonian_cycle.rs
    │   ├── knight_tour.rs
    │   ├── mod.rs
    │   ├── n_queens.rs
    │   ├── parentheses_generator.rs
    │   ├── permutations.rs
    │   ├── rat_in_maze.rs
    │   ├── subset_sum.rs
    │   └── sudoku.rs
    ├── big_integer/
    │   ├── fast_factorial.rs
    │   ├── mod.rs
    │   ├── multiply.rs
    │   └── poly1305.rs
    ├── bit_manipulation/
    │   ├── binary_coded_decimal.rs
    │   ├── binary_count_trailing_zeros.rs
    │   ├── binary_shifts.rs
    │   ├── counting_bits.rs
    │   ├── find_missing_number.rs
    │   ├── find_previous_power_of_two.rs
    │   ├── find_unique_number.rs
    │   ├── hamming_distance.rs
    │   ├── highest_set_bit.rs
    │   ├── is_power_of_two.rs
    │   ├── mod.rs
    │   ├── n_bits_gray_code.rs
    │   ├── reverse_bits.rs
    │   ├── rightmost_set_bit.rs
    │   ├── sum_of_two_integers.rs
    │   ├── swap_odd_even_bits.rs
    │   └── twos_complement.rs
    ├── ciphers/
    │   ├── README.md
    │   ├── aes.rs
    │   ├── affine_cipher.rs
    │   ├── another_rot13.rs
    │   ├── baconian_cipher.rs
    │   ├── base16.rs
    │   ├── base32.rs
    │   ├── base64.rs
    │   ├── base85.rs
    │   ├── blake2b.rs
    │   ├── caesar.rs
    │   ├── chacha.rs
    │   ├── diffie_hellman.rs
    │   ├── hashing_traits.rs
    │   ├── hill_cipher.rs
    │   ├── kernighan.rs
    │   ├── mod.rs
    │   ├── morse_code.rs
    │   ├── polybius.rs
    │   ├── rail_fence.rs
    │   ├── rot13.rs
    │   ├── rsa_cipher.rs
    │   ├── salsa.rs
    │   ├── sha256.rs
    │   ├── sha3.rs
    │   ├── tea.rs
    │   ├── theoretical_rot13.rs
    │   ├── transposition.rs
    │   ├── trifid.rs
    │   ├── vernam.rs
    │   ├── vigenere.rs
    │   └── xor.rs
    ├── compression/
    │   ├── burrows_wheeler_transform.rs
    │   ├── huffman_encoding.rs
    │   ├── lz77.rs
    │   ├── mod.rs
    │   ├── move_to_front.rs
    │   └── run_length_encoding.rs
    ├── conversions/
    │   ├── binary_to_decimal.rs
    │   ├── binary_to_hexadecimal.rs
    │   ├── binary_to_octal.rs
    │   ├── decimal_to_binary.rs
    │   ├── decimal_to_hexadecimal.rs
    │   ├── decimal_to_octal.rs
    │   ├── energy.rs
    │   ├── hexadecimal_to_binary.rs
    │   ├── hexadecimal_to_decimal.rs
    │   ├── hexadecimal_to_octal.rs
    │   ├── ipv4_conversion.rs
    │   ├── length_conversion.rs
    │   ├── mod.rs
    │   ├── octal_to_binary.rs
    │   ├── octal_to_decimal.rs
    │   ├── octal_to_hexadecimal.rs
    │   ├── order_of_magnitude_conversion.rs
    │   ├── pressure.rs
    │   ├── rectangular_to_polar.rs
    │   ├── rgb_cmyk_conversion.rs
    │   ├── rgb_hsv_conversion.rs
    │   ├── roman_numerals.rs
    │   ├── speed.rs
    │   ├── temperature.rs
    │   ├── time.rs
    │   ├── volume.rs
    │   └── weight.rs
    ├── data_structures/
    │   ├── README.md
    │   ├── avl_tree.rs
    │   ├── b_tree.rs
    │   ├── binary_search_tree.rs
    │   ├── fenwick_tree.rs
    │   ├── floyds_algorithm.rs
    │   ├── graph.rs
    │   ├── hash_table.rs
    │   ├── heap.rs
    │   ├── lazy_segment_tree.rs
    │   ├── linked_list.rs
    │   ├── mod.rs
    │   ├── probabilistic/
    │   │   ├── bloom_filter.rs
    │   │   ├── count_min_sketch.rs
    │   │   └── mod.rs
    │   ├── queue.rs
    │   ├── range_minimum_query.rs
    │   ├── rb_tree.rs
    │   ├── segment_tree.rs
    │   ├── segment_tree_recursive.rs
    │   ├── skip_list.rs
    │   ├── stack_using_singly_linked_list.rs
    │   ├── treap.rs
    │   ├── trie.rs
    │   ├── union_find.rs
    │   └── veb_tree.rs
    ├── dynamic_programming/
    │   ├── catalan_numbers.rs
    │   ├── coin_change.rs
    │   ├── egg_dropping.rs
    │   ├── fibonacci.rs
    │   ├── fractional_knapsack.rs
    │   ├── integer_partition.rs
    │   ├── is_subsequence.rs
    │   ├── knapsack.rs
    │   ├── longest_common_subsequence.rs
    │   ├── longest_common_substring.rs
    │   ├── longest_continuous_increasing_subsequence.rs
    │   ├── longest_increasing_subsequence.rs
    │   ├── matrix_chain_multiply.rs
    │   ├── maximal_square.rs
    │   ├── maximum_subarray.rs
    │   ├── minimum_cost_path.rs
    │   ├── mod.rs
    │   ├── optimal_bst.rs
    │   ├── palindrome_partitioning.rs
    │   ├── rod_cutting.rs
    │   ├── smith_waterman.rs
    │   ├── snail.rs
    │   ├── subset_generation.rs
    │   ├── subset_sum.rs
    │   ├── task_assignment.rs
    │   ├── trapped_rainwater.rs
    │   └── word_break.rs
    ├── financial/
    │   ├── depreciation.rs
    │   ├── equated_monthly_installments.rs
    │   ├── exponential_moving_average.rs
    │   ├── finance_ratios.rs
    │   ├── interest.rs
    │   ├── mod.rs
    │   ├── npv.rs
    │   ├── npv_sensitivity.rs
    │   ├── payback.rs
    │   ├── present_value.rs
    │   └── treynor_ratio.rs
    ├── general/
    │   ├── convex_hull.rs
    │   ├── fisher_yates_shuffle.rs
    │   ├── genetic.rs
    │   ├── hanoi.rs
    │   ├── huffman_encoding.rs
    │   ├── kadane_algorithm.rs
    │   ├── kmeans.rs
    │   ├── mex.rs
    │   ├── mod.rs
    │   ├── permutations/
    │   │   ├── heap.rs
    │   │   ├── mod.rs
    │   │   ├── naive.rs
    │   │   └── steinhaus_johnson_trotter.rs
    │   ├── subarray_sum_equals_k.rs
    │   └── two_sum.rs
    ├── geometry/
    │   ├── closest_points.rs
    │   ├── graham_scan.rs
    │   ├── jarvis_scan.rs
    │   ├── mod.rs
    │   ├── point.rs
    │   ├── polygon_points.rs
    │   ├── ramer_douglas_peucker.rs
    │   └── segment.rs
    ├── graph/
    │   ├── ant_colony_optimization.rs
    │   ├── astar.rs
    │   ├── bellman_ford.rs
    │   ├── bipartite_matching.rs
    │   ├── breadth_first_search.rs
    │   ├── centroid_decomposition.rs
    │   ├── decremental_connectivity.rs
    │   ├── depth_first_search.rs
    │   ├── depth_first_search_tic_tac_toe.rs
    │   ├── detect_cycle.rs
    │   ├── dijkstra.rs
    │   ├── dinic_maxflow.rs
    │   ├── disjoint_set_union.rs
    │   ├── eulerian_path.rs
    │   ├── floyd_warshall.rs
    │   ├── ford_fulkerson.rs
    │   ├── graph_enumeration.rs
    │   ├── heavy_light_decomposition.rs
    │   ├── kosaraju.rs
    │   ├── lee_breadth_first_search.rs
    │   ├── lowest_common_ancestor.rs
    │   ├── minimum_spanning_tree.rs
    │   ├── mod.rs
    │   ├── prim.rs
    │   ├── prufer_code.rs
    │   ├── strongly_connected_components.rs
    │   ├── tarjans_ssc.rs
    │   ├── topological_sort.rs
    │   └── two_satisfiability.rs
    ├── greedy/
    │   ├── minimum_coin_change.rs
    │   ├── mod.rs
    │   ├── smallest_range.rs
    │   └── stable_matching.rs
    ├── lib.rs
    ├── machine_learning/
    │   ├── cholesky.rs
    │   ├── decision_tree.rs
    │   ├── k_means.rs
    │   ├── k_nearest_neighbors.rs
    │   ├── linear_regression.rs
    │   ├── logistic_regression.rs
    │   ├── loss_function/
    │   │   ├── average_margin_ranking_loss.rs
    │   │   ├── hinge_loss.rs
    │   │   ├── huber_loss.rs
    │   │   ├── kl_divergence_loss.rs
    │   │   ├── mean_absolute_error_loss.rs
    │   │   ├── mean_squared_error_loss.rs
    │   │   ├── mod.rs
    │   │   └── negative_log_likelihood.rs
    │   ├── mod.rs
    │   ├── naive_bayes.rs
    │   ├── optimization/
    │   │   ├── adam.rs
    │   │   ├── gradient_descent.rs
    │   │   ├── mod.rs
    │   │   └── momentum.rs
    │   ├── perceptron.rs
    │   ├── principal_component_analysis.rs
    │   ├── random_forest.rs
    │   └── support_vector_classifier.rs
    ├── math/
    │   ├── abs.rs
    │   ├── aliquot_sum.rs
    │   ├── amicable_numbers.rs
    │   ├── area_of_polygon.rs
    │   ├── area_under_curve.rs
    │   ├── armstrong_number.rs
    │   ├── average.rs
    │   ├── baby_step_giant_step.rs
    │   ├── bell_numbers.rs
    │   ├── binary_exponentiation.rs
    │   ├── binomial_coefficient.rs
    │   ├── catalan_numbers.rs
    │   ├── ceil.rs
    │   ├── chinese_remainder_theorem.rs
    │   ├── collatz_sequence.rs
    │   ├── combinations.rs
    │   ├── cross_entropy_loss.rs
    │   ├── decimal_to_fraction.rs
    │   ├── doomsday.rs
    │   ├── elliptic_curve.rs
    │   ├── euclidean_distance.rs
    │   ├── exponential_linear_unit.rs
    │   ├── extended_euclidean_algorithm.rs
    │   ├── factorial.rs
    │   ├── factors.rs
    │   ├── fast_fourier_transform.rs
    │   ├── fast_power.rs
    │   ├── faster_perfect_numbers.rs
    │   ├── field.rs
    │   ├── frizzy_number.rs
    │   ├── gaussian_elimination.rs
    │   ├── gaussian_error_linear_unit.rs
    │   ├── gcd_of_n_numbers.rs
    │   ├── geometric_series.rs
    │   ├── greatest_common_divisor.rs
    │   ├── huber_loss.rs
    │   ├── infix_to_postfix.rs
    │   ├── interest.rs
    │   ├── interpolation.rs
    │   ├── interquartile_range.rs
    │   ├── karatsuba_multiplication.rs
    │   ├── lcm_of_n_numbers.rs
    │   ├── leaky_relu.rs
    │   ├── least_square_approx.rs
    │   ├── linear_sieve.rs
    │   ├── logarithm.rs
    │   ├── lucas_series.rs
    │   ├── matrix_ops.rs
    │   ├── mersenne_primes.rs
    │   ├── miller_rabin.rs
    │   ├── mod.rs
    │   ├── modular_exponential.rs
    │   ├── newton_raphson.rs
    │   ├── nthprime.rs
    │   ├── pascal_triangle.rs
    │   ├── perfect_cube.rs
    │   ├── perfect_numbers.rs
    │   ├── perfect_square.rs
    │   ├── pollard_rho.rs
    │   ├── postfix_evaluation.rs
    │   ├── prime_check.rs
    │   ├── prime_factors.rs
    │   ├── prime_numbers.rs
    │   ├── quadratic_residue.rs
    │   ├── random.rs
    │   ├── relu.rs
    │   ├── sieve_of_eratosthenes.rs
    │   ├── sigmoid.rs
    │   ├── signum.rs
    │   ├── simpsons_integration.rs
    │   ├── softmax.rs
    │   ├── sprague_grundy_theorem.rs
    │   ├── square_pyramidal_numbers.rs
    │   ├── square_root.rs
    │   ├── sum_of_digits.rs
    │   ├── sum_of_geometric_progression.rs
    │   ├── sum_of_harmonic_series.rs
    │   ├── sylvester_sequence.rs
    │   ├── tanh.rs
    │   ├── trapezoidal_integration.rs
    │   ├── trial_division.rs
    │   ├── trig_functions.rs
    │   ├── vector_cross_product.rs
    │   └── zellers_congruence_algorithm.rs
    ├── navigation/
    │   ├── bearing.rs
    │   ├── haversine.rs
    │   ├── mod.rs
    │   └── rhumbline.rs
    ├── number_theory/
    │   ├── compute_totient.rs
    │   ├── euler_totient.rs
    │   ├── kth_factor.rs
    │   └── mod.rs
    ├── searching/
    │   ├── README.md
    │   ├── binary_search.rs
    │   ├── binary_search_recursive.rs
    │   ├── exponential_search.rs
    │   ├── fibonacci_search.rs
    │   ├── interpolation_search.rs
    │   ├── jump_search.rs
    │   ├── kth_smallest.rs
    │   ├── kth_smallest_heap.rs
    │   ├── linear_search.rs
    │   ├── mod.rs
    │   ├── moore_voting.rs
    │   ├── quick_select.rs
    │   ├── saddleback_search.rs
    │   ├── ternary_search.rs
    │   ├── ternary_search_min_max.rs
    │   ├── ternary_search_min_max_recursive.rs
    │   └── ternary_search_recursive.rs
    ├── signal_analysis/
    │   ├── mod.rs
    │   └── yin.rs
    ├── sorting/
    │   ├── README.md
    │   ├── bead_sort.rs
    │   ├── binary_insertion_sort.rs
    │   ├── bingo_sort.rs
    │   ├── bitonic_sort.rs
    │   ├── bogo_sort.rs
    │   ├── bubble_sort.rs
    │   ├── bucket_sort.rs
    │   ├── cocktail_shaker_sort.rs
    │   ├── comb_sort.rs
    │   ├── counting_sort.rs
    │   ├── cycle_sort.rs
    │   ├── dutch_national_flag_sort.rs
    │   ├── exchange_sort.rs
    │   ├── gnome_sort.rs
    │   ├── heap_sort.rs
    │   ├── insertion_sort.rs
    │   ├── intro_sort.rs
    │   ├── merge_sort.rs
    │   ├── mod.rs
    │   ├── odd_even_sort.rs
    │   ├── pancake_sort.rs
    │   ├── patience_sort.rs
    │   ├── pigeonhole_sort.rs
    │   ├── quick_sort.rs
    │   ├── quick_sort_3_ways.rs
    │   ├── radix_sort.rs
    │   ├── selection_sort.rs
    │   ├── shell_sort.rs
    │   ├── sleep_sort.rs
    │   ├── sort_utils.rs
    │   ├── stooge_sort.rs
    │   ├── tim_sort.rs
    │   ├── tree_sort.rs
    │   ├── wave_sort.rs
    │   └── wiggle_sort.rs
    └── string/
        ├── README.md
        ├── aho_corasick.rs
        ├── anagram.rs
        ├── autocomplete_using_trie.rs
        ├── boyer_moore_search.rs
        ├── burrows_wheeler_transform.rs
        ├── duval_algorithm.rs
        ├── hamming_distance.rs
        ├── isogram.rs
        ├── isomorphism.rs
        ├── jaro_winkler_distance.rs
        ├── knuth_morris_pratt.rs
        ├── levenshtein_distance.rs
        ├── lipogram.rs
        ├── manacher.rs
        ├── mod.rs
        ├── palindrome.rs
        ├── pangram.rs
        ├── rabin_karp.rs
        ├── reverse.rs
        ├── run_length_encoding.rs
        ├── shortest_palindrome.rs
        ├── suffix_array.rs
        ├── suffix_array_manber_myers.rs
        ├── suffix_tree.rs
        └── z_algorithm.rs
Download .txt
Showing preview only (266K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3217 symbols across 389 files)

FILE: .github/workflows/scripts/build_directory/src/lib.rs
  function good_filepaths (line 9) | fn good_filepaths(top_dir: &Path) -> Result<Vec<String>, Box<dyn Error>> {
  function md_prefix (line 41) | fn md_prefix(indent_count: usize) -> String {
  function print_path (line 49) | fn print_path(old_path: String, new_path: String) -> (String, String) {
  function build_directory_md (line 63) | pub fn build_directory_md(top_dir: &Path) -> Result<String, Box<dyn Erro...
  function to_title (line 86) | fn to_title(name: &str) -> String {
  function get_addr (line 106) | fn get_addr(addr: &str) -> String {
  function switch_backslash (line 115) | fn switch_backslash(addr: &str) -> String {

FILE: .github/workflows/scripts/build_directory/src/main.rs
  function main (line 4) | fn main() -> Result<(), std::io::Error> {

FILE: src/backtracking/all_combination_of_size_k.rs
  type CombinationError (line 6) | pub enum CombinationError {
  function generate_all_combinations (line 22) | pub fn generate_all_combinations(n: usize, k: usize) -> Result<Vec<Vec<u...
  function backtrack (line 47) | fn backtrack(

FILE: src/backtracking/graph_coloring.rs
  type GraphColoringError (line 7) | pub enum GraphColoringError {
  function generate_colorings (line 25) | pub fn generate_colorings(
  type GraphColoring (line 33) | struct GraphColoring {
    method new (line 52) | fn new(adjacency_matrix: Vec<Vec<bool>>) -> Result<Self, GraphColoring...
    method num_vertices (line 73) | fn num_vertices(&self) -> usize {
    method is_color_valid (line 87) | fn is_color_valid(&self, vertex: usize, color: usize) -> bool {
    method find_colorings (line 105) | fn find_colorings(&mut self, vertex: usize, num_colors: usize) {
    method find_solutions (line 129) | fn find_solutions(&mut self, num_colors: usize) -> Option<Vec<Vec<usiz...

FILE: src/backtracking/hamiltonian_cycle.rs
  type FindHamiltonianCycleError (line 6) | pub enum FindHamiltonianCycleError {
  type Graph (line 16) | struct Graph {
    method new (line 33) | fn new(adjacency_matrix: Vec<Vec<bool>>) -> Result<Self, FindHamiltoni...
    method num_vertices (line 51) | fn num_vertices(&self) -> usize {
    method is_safe (line 67) | fn is_safe(&self, v: usize, visited: &[bool], path: &[Option<usize>], ...
    method hamiltonian_cycle_util (line 90) | fn hamiltonian_cycle_util(
    method find_hamiltonian_cycle (line 131) | fn find_hamiltonian_cycle(
  function find_hamiltonian_cycle (line 160) | pub fn find_hamiltonian_cycle(

FILE: src/backtracking/knight_tour.rs
  function find_knight_tour (line 20) | pub fn find_knight_tour(
  type KnightTour (line 31) | struct KnightTour {
    constant MOVES (line 37) | const MOVES: [(isize, isize); 8] = [
    method new (line 57) | fn new(size_x: usize, size_y: usize) -> Self {
    method size_x (line 63) | fn size_x(&self) -> usize {
    method size_y (line 68) | fn size_y(&self) -> usize {
    method is_safe (line 82) | fn is_safe(&self, x: isize, y: isize) -> bool {
    method solve_tour (line 101) | fn solve_tour(&mut self, x: isize, y: isize, move_count: usize) -> bool {
    method find_tour (line 133) | fn find_tour(&mut self, start_x: usize, start_y: usize) -> Option<Vec<...

FILE: src/backtracking/n_queens.rs
  function n_queens_solver (line 22) | pub fn n_queens_solver(n: usize) -> Vec<Vec<String>> {
  type NQueensSolver (line 28) | struct NQueensSolver {
    method new (line 47) | fn new(size: usize) -> Self {
    method solve (line 60) | fn solve(&mut self) -> Vec<Vec<String>> {
    method is_safe (line 75) | fn is_safe(&self, row: usize, col: usize) -> bool {
    method solve_helper (line 93) | fn solve_helper(&mut self, row: usize) {

FILE: src/backtracking/parentheses_generator.rs
  function generate_parentheses (line 9) | pub fn generate_parentheses(n: usize) -> Vec<String> {
  function generate (line 30) | fn generate(

FILE: src/backtracking/permutations.rs
  function permute (line 14) | pub fn permute(mut nums: Vec<isize>) -> Vec<Vec<isize>> {
  function generate (line 33) | fn generate(

FILE: src/backtracking/rat_in_maze.rs
  type MazeError (line 9) | pub enum MazeError {
  function find_path_in_maze (line 43) | pub fn find_path_in_maze(
  type Maze (line 68) | struct Maze {
    constant MOVES (line 74) | const MOVES: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)];
    method new (line 85) | fn new(maze: Vec<Vec<bool>>) -> Self {
    method width (line 94) | fn width(&self) -> usize {
    method height (line 103) | fn height(&self) -> usize {
    method find_path (line 117) | fn find_path(&self, start_x: usize, start_y: usize) -> Option<Vec<Vec<...
    method solve (line 137) | fn solve(&self, x: isize, y: isize, solution: &mut [Vec<bool>]) -> bool {
    method is_valid (line 170) | fn is_valid(&self, x: isize, y: isize, solution: &[Vec<bool>]) -> bool {

FILE: src/backtracking/subset_sum.rs
  function has_subset_with_sum (line 5) | pub fn has_subset_with_sum(set: &[isize], target: isize) -> bool {
  function backtrack (line 9) | fn backtrack(set: &[isize], remaining_items: usize, target: isize) -> bo...

FILE: src/backtracking/sudoku.rs
  function sudoku_solver (line 13) | pub fn sudoku_solver(board: &[[u8; 9]; 9]) -> Option<[[u8; 9]; 9]> {
  type SudokuSolver (line 23) | struct SudokuSolver {
    method new (line 30) | fn new(board: [[u8; 9]; 9]) -> SudokuSolver {
    method find_empty_cell (line 37) | fn find_empty_cell(&self) -> Option<(usize, usize)> {
    method is_value_valid (line 53) | fn is_value_valid(&self, coordinates: (usize, usize), value: u8) -> bo...
    method solve (line 89) | fn solve(&mut self) -> bool {

FILE: src/big_integer/fast_factorial.rs
  function index (line 10) | fn index(p: usize, n: usize) -> usize {
  function fast_factorial (line 25) | pub fn fast_factorial(n: usize) -> BigUint {
  function fact (line 68) | fn fact() {

FILE: src/big_integer/multiply.rs
  function multiply (line 2) | pub fn multiply(num1: &str, num2: &str) -> String {
  function is_valid_nonnegative (line 28) | pub fn is_valid_nonnegative(num: &str) -> bool {

FILE: src/big_integer/poly1305.rs
  type Poly1305 (line 17) | pub struct Poly1305 {
    method new (line 32) | pub fn new() -> Self {
    method clamp_r (line 40) | pub fn clamp_r(&mut self) {
    method set_key (line 43) | pub fn set_key(&mut self, key: &[u8; 32]) {
    method add_msg (line 51) | pub fn add_msg(&mut self, msg: &[u8; 16], msg_bytes: u64) {
    method get_tag (line 59) | pub fn get_tag(&self) -> Vec<u8> {
  method default (line 26) | fn default() -> Self {
  function get_tag_hex (line 71) | fn get_tag_hex(tag: &[u8]) -> String {
  function basic_tv1 (line 79) | fn basic_tv1() {

FILE: src/bit_manipulation/binary_coded_decimal.rs
  function binary_coded_decimal (line 50) | pub fn binary_coded_decimal(number: i32) -> String {
  function test_zero (line 73) | fn test_zero() {
  function test_single_digit (line 78) | fn test_single_digit() {
  function test_two_digits (line 91) | fn test_two_digits() {
  function test_three_digits (line 99) | fn test_three_digits() {
  function test_large_numbers (line 107) | fn test_large_numbers() {
  function test_negative_numbers (line 113) | fn test_negative_numbers() {
  function test_each_digit_encoding (line 121) | fn test_each_digit_encoding() {

FILE: src/bit_manipulation/binary_count_trailing_zeros.rs
  function binary_count_trailing_zeros (line 21) | pub fn binary_count_trailing_zeros(num: u64) -> u32 {
  function binary_count_trailing_zeros_bitwise (line 47) | pub fn binary_count_trailing_zeros_bitwise(num: u64) -> u32 {
  function test_basic_cases (line 61) | fn test_basic_cases() {
  function test_zero (line 70) | fn test_zero() {
  function test_powers_of_two (line 75) | fn test_powers_of_two() {
  function test_bitwise_vs_builtin (line 84) | fn test_bitwise_vs_builtin() {

FILE: src/bit_manipulation/binary_shifts.rs
  function logical_left_shift (line 54) | pub fn logical_left_shift(number: i32, shift_amount: i32) -> Result<Stri...
  function logical_right_shift (line 94) | pub fn logical_right_shift(number: i32, shift_amount: i32) -> Result<Str...
  function arithmetic_right_shift (line 131) | pub fn arithmetic_right_shift(number: i32, shift_amount: i32) -> Result<...
  function arithmetic_left_shift (line 220) | pub fn arithmetic_left_shift(number: i32, shift_amount: i32) -> Result<S...
  function test_logical_left_shift_zero (line 238) | fn test_logical_left_shift_zero() {
  function test_logical_left_shift_one (line 243) | fn test_logical_left_shift_one() {
  function test_logical_left_shift_large_shift (line 248) | fn test_logical_left_shift_large_shift() {
  function test_logical_left_shift_seventeen (line 253) | fn test_logical_left_shift_seventeen() {
  function test_logical_left_shift_large_number (line 258) | fn test_logical_left_shift_large_number() {
  function test_logical_left_shift_negative_number (line 263) | fn test_logical_left_shift_negative_number() {
  function test_logical_left_shift_negative_shift (line 268) | fn test_logical_left_shift_negative_shift() {
  function test_logical_left_shift_both_negative (line 273) | fn test_logical_left_shift_both_negative() {
  function test_logical_right_shift_zero (line 279) | fn test_logical_right_shift_zero() {
  function test_logical_right_shift_one (line 284) | fn test_logical_right_shift_one() {
  function test_logical_right_shift_shift_all_bits (line 289) | fn test_logical_right_shift_shift_all_bits() {
  function test_logical_right_shift_seventeen (line 294) | fn test_logical_right_shift_seventeen() {
  function test_logical_right_shift_large_number (line 299) | fn test_logical_right_shift_large_number() {
  function test_logical_right_shift_negative_number (line 304) | fn test_logical_right_shift_negative_number() {
  function test_logical_right_shift_negative_shift (line 309) | fn test_logical_right_shift_negative_shift() {
  function test_logical_right_shift_both_negative (line 314) | fn test_logical_right_shift_both_negative() {
  function test_arithmetic_right_shift_zero (line 320) | fn test_arithmetic_right_shift_zero() {
  function test_arithmetic_right_shift_one (line 325) | fn test_arithmetic_right_shift_one() {
  function test_arithmetic_right_shift_negative_one (line 330) | fn test_arithmetic_right_shift_negative_one() {
  function test_arithmetic_right_shift_seventeen_positive (line 335) | fn test_arithmetic_right_shift_seventeen_positive() {
  function test_arithmetic_right_shift_seventeen_negative (line 340) | fn test_arithmetic_right_shift_seventeen_negative() {
  function test_arithmetic_right_shift_large_negative (line 345) | fn test_arithmetic_right_shift_large_negative() {
  function test_arithmetic_right_shift_negative_shift (line 350) | fn test_arithmetic_right_shift_negative_shift() {
  function test_arithmetic_right_shift_preserves_sign_positive (line 355) | fn test_arithmetic_right_shift_preserves_sign_positive() {
  function test_arithmetic_right_shift_preserves_sign_negative (line 364) | fn test_arithmetic_right_shift_preserves_sign_negative() {
  function test_arithmetic_right_shift_large_shift_positive (line 371) | fn test_arithmetic_right_shift_large_shift_positive() {
  function test_arithmetic_right_shift_large_shift_negative (line 379) | fn test_arithmetic_right_shift_large_shift_negative() {
  function test_arithmetic_left_shift_basic (line 390) | fn test_arithmetic_left_shift_basic() {
  function test_arithmetic_left_shift_negative (line 396) | fn test_arithmetic_left_shift_negative() {
  function test_arithmetic_left_shift_zero (line 406) | fn test_arithmetic_left_shift_zero() {
  function test_arithmetic_left_shift_negative_shift (line 411) | fn test_arithmetic_left_shift_negative_shift() {
  function test_arithmetic_left_shift_same_as_logical (line 416) | fn test_arithmetic_left_shift_same_as_logical() {
  function test_all_shifts_on_same_value (line 430) | fn test_all_shifts_on_same_value() {

FILE: src/bit_manipulation/counting_bits.rs
  function count_set_bits (line 16) | pub fn count_set_bits(mut n: usize) -> usize {

FILE: src/bit_manipulation/find_missing_number.rs
  function find_missing_number (line 27) | pub fn find_missing_number(nums: &[i32]) -> Result<i32, String> {
  function test_missing_in_middle (line 54) | fn test_missing_in_middle() {
  function test_unordered_array (line 59) | fn test_unordered_array() {
  function test_negative_numbers (line 64) | fn test_negative_numbers() {
  function test_negative_and_positive (line 69) | fn test_negative_and_positive() {
  function test_missing_at_start (line 74) | fn test_missing_at_start() {
  function test_unordered_missing_middle (line 79) | fn test_unordered_missing_middle() {
  function test_another_unordered (line 84) | fn test_another_unordered() {
  function test_empty_array (line 89) | fn test_empty_array() {
  function test_single_element (line 98) | fn test_single_element() {
  function test_two_elements (line 107) | fn test_two_elements() {
  function test_large_range (line 113) | fn test_large_range() {
  function test_missing_at_boundaries (line 118) | fn test_missing_at_boundaries() {

FILE: src/bit_manipulation/find_previous_power_of_two.rs
  function find_previous_power_of_two (line 53) | pub fn find_previous_power_of_two(number: i32) -> Result<u32, String> {
  function test_zero (line 77) | fn test_zero() {
  function test_one (line 82) | fn test_one() {
  function test_powers_of_two (line 87) | fn test_powers_of_two() {
  function test_numbers_between_powers (line 101) | fn test_numbers_between_powers() {
  function test_range_0_to_17 (line 126) | fn test_range_0_to_17() {
  function test_large_numbers (line 136) | fn test_large_numbers() {
  function test_max_safe_values (line 145) | fn test_max_safe_values() {
  function test_negative_number_returns_error (line 152) | fn test_negative_number_returns_error() {
  function test_negative_numbers_return_errors (line 159) | fn test_negative_numbers_return_errors() {
  function test_edge_cases (line 166) | fn test_edge_cases() {

FILE: src/bit_manipulation/find_unique_number.rs
  function find_unique_number (line 26) | pub fn find_unique_number(arr: &[i32]) -> Result<i32, String> {
  function test_basic_case (line 40) | fn test_basic_case() {
  function test_different_order (line 45) | fn test_different_order() {
  function test_single_element (line 50) | fn test_single_element() {
  function test_three_elements (line 55) | fn test_three_elements() {
  function test_empty_array (line 60) | fn test_empty_array() {
  function test_negative_numbers (line 69) | fn test_negative_numbers() {
  function test_large_numbers (line 74) | fn test_large_numbers() {
  function test_zero (line 82) | fn test_zero() {

FILE: src/bit_manipulation/hamming_distance.rs
  function bit_count (line 25) | fn bit_count(mut value: u64) -> u64 {
  function hamming_distance (line 59) | pub fn hamming_distance(a: u64, b: u64) -> u64 {
  function hamming_distance_str (line 89) | pub fn hamming_distance_str(a: &str, b: &str) -> u64 {
  function test_bit_count (line 107) | fn test_bit_count() {
  function test_hamming_distance_integers (line 114) | fn test_hamming_distance_integers() {
  function test_hamming_distance_strings (line 122) | fn test_hamming_distance_strings() {
  function test_hamming_distance_strings_different_lengths (line 133) | fn test_hamming_distance_strings_different_lengths() {

FILE: src/bit_manipulation/highest_set_bit.rs
  function find_highest_set_bit (line 13) | pub fn find_highest_set_bit(num: usize) -> Option<usize> {

FILE: src/bit_manipulation/is_power_of_two.rs
  function is_power_of_two (line 70) | pub fn is_power_of_two(number: i32) -> Result<bool, String> {
  function test_zero (line 88) | fn test_zero() {
  function test_one (line 94) | fn test_one() {
  function test_powers_of_two (line 100) | fn test_powers_of_two() {
  function test_non_powers_of_two (line 120) | fn test_non_powers_of_two() {
  function test_specific_non_powers (line 137) | fn test_specific_non_powers() {
  function test_large_powers_of_two (line 145) | fn test_large_powers_of_two() {
  function test_numbers_near_powers_of_two (line 153) | fn test_numbers_near_powers_of_two() {
  function test_negative_number_returns_error (line 174) | fn test_negative_number_returns_error() {
  function test_multiple_negative_numbers (line 181) | fn test_multiple_negative_numbers() {
  function test_all_powers_of_two_up_to_30 (line 190) | fn test_all_powers_of_two_up_to_30() {
  function test_range_verification (line 202) | fn test_range_verification() {
  function test_bit_manipulation_correctness (line 220) | fn test_bit_manipulation_correctness() {
  function test_edge_case_max_i32_power_of_two (line 236) | fn test_edge_case_max_i32_power_of_two() {

FILE: src/bit_manipulation/n_bits_gray_code.rs
  type GrayCodeError (line 3) | pub enum GrayCodeError {
  function generate_gray_code (line 16) | pub fn generate_gray_code(n: usize) -> Result<Vec<String>, GrayCodeError> {

FILE: src/bit_manipulation/reverse_bits.rs
  function reverse_bits (line 60) | pub fn reverse_bits(n: u32) -> u32 {
  function test_reverse_bits_basic (line 84) | fn test_reverse_bits_basic() {
  function test_reverse_bits_one (line 91) | fn test_reverse_bits_one() {
  function test_reverse_bits_all_ones (line 98) | fn test_reverse_bits_all_ones() {
  function test_reverse_bits_zero (line 105) | fn test_reverse_bits_zero() {
  function test_reverse_bits_max (line 112) | fn test_reverse_bits_max() {
  function test_reverse_bits_alternating (line 119) | fn test_reverse_bits_alternating() {
  function test_reverse_bits_symmetric (line 126) | fn test_reverse_bits_symmetric() {

FILE: src/bit_manipulation/rightmost_set_bit.rs
  function index_of_rightmost_set_bit (line 41) | pub fn index_of_rightmost_set_bit(num: i32) -> Result<u32, String> {
  function index_of_rightmost_set_bit_log (line 69) | pub fn index_of_rightmost_set_bit_log(num: i32) -> Result<u32, String> {
  function test_basic_cases (line 88) | fn test_basic_cases() {
  function test_powers_of_two (line 100) | fn test_powers_of_two() {
  function test_odd_numbers (line 121) | fn test_odd_numbers() {
  function test_even_numbers (line 131) | fn test_even_numbers() {
  function test_zero (line 143) | fn test_zero() {
  function test_negative_numbers (line 152) | fn test_negative_numbers() {
  function test_large_numbers (line 162) | fn test_large_numbers() {
  function test_consecutive_numbers (line 174) | fn test_consecutive_numbers() {
  function test_log_version (line 183) | fn test_log_version() {
  function test_both_implementations_match (line 192) | fn test_both_implementations_match() {

FILE: src/bit_manipulation/sum_of_two_integers.rs
  function add_two_integers (line 14) | pub fn add_two_integers(mut a: isize, mut b: isize) -> isize {

FILE: src/bit_manipulation/swap_odd_even_bits.rs
  function swap_odd_even_bits (line 28) | pub fn swap_odd_even_bits(num: u32) -> u32 {
  function test_swap_odd_even_bits (line 44) | fn test_swap_odd_even_bits() {
  function test_edge_cases (line 57) | fn test_edge_cases() {
  function test_power_of_two (line 67) | fn test_power_of_two() {

FILE: src/bit_manipulation/twos_complement.rs
  function twos_complement (line 43) | pub fn twos_complement(number: i32) -> Result<String, String> {
  function test_zero (line 78) | fn test_zero() {
  function test_negative_one (line 83) | fn test_negative_one() {
  function test_negative_five (line 88) | fn test_negative_five() {
  function test_negative_seventeen (line 93) | fn test_negative_seventeen() {
  function test_negative_two_hundred_seven (line 98) | fn test_negative_two_hundred_seven() {
  function test_negative_small_values (line 103) | fn test_negative_small_values() {
  function test_negative_larger_values (line 110) | fn test_negative_larger_values() {
  function test_positive_number_returns_error (line 117) | fn test_positive_number_returns_error() {
  function test_large_positive_number_returns_error (line 124) | fn test_large_positive_number_returns_error() {
  function test_edge_case_negative_powers_of_two (line 131) | fn test_edge_case_negative_powers_of_two() {

FILE: src/ciphers/aes.rs
  constant AES_WORD_SIZE (line 1) | const AES_WORD_SIZE: usize = 4;
  constant AES_BLOCK_SIZE (line 2) | const AES_BLOCK_SIZE: usize = 16;
  constant AES_NUM_BLOCK_WORDS (line 3) | const AES_NUM_BLOCK_WORDS: usize = AES_BLOCK_SIZE / AES_WORD_SIZE;
  type Byte (line 5) | type Byte = u8;
  type Word (line 6) | type Word = u32;
  type AesWord (line 8) | type AesWord = [Byte; AES_WORD_SIZE];
  constant RCON (line 12) | const RCON: [Word; 256] = [
  constant SBOX (line 34) | const SBOX: [Byte; 256] = [
  constant INV_SBOX (line 56) | const INV_SBOX: [Byte; 256] = [
  constant GF_MUL_TABLE (line 77) | const GF_MUL_TABLE: [[Byte; 256]; 16] = [
  type AesKey (line 222) | pub enum AesKey {
  type AesMode (line 229) | enum AesMode {
  function aes_encrypt (line 234) | pub fn aes_encrypt(plain_text: &[Byte], key: AesKey) -> Vec<Byte> {
  function aes_decrypt (line 263) | pub fn aes_decrypt(cipher_text: &[Byte], key: AesKey) -> Vec<Byte> {
  function key_expansion (line 292) | fn key_expansion(init_key: &[Byte], num_rounds: usize) -> Vec<Byte> {
  function add_round_key (line 320) | fn add_round_key(data: &mut [Byte], round_key: &[Byte]) {
  function sub_bytes_blocks (line 328) | fn sub_bytes_blocks(data: &mut [Byte], mode: AesMode) {
  function shift_rows_blocks (line 334) | fn shift_rows_blocks(blocks: &mut [Byte], mode: AesMode) {
  function mix_column_blocks (line 342) | fn mix_column_blocks(data: &mut [Byte], mode: AesMode) {
  function padding (line 350) | fn padding<T: Clone + Default>(data: &[T], block_size: usize) -> Vec<T> {
  function sub_word (line 364) | fn sub_word(word: Word, mode: AesMode) -> Word {
  function sub_bytes (line 370) | fn sub_bytes(data: &mut [Byte], mode: AesMode) {
  function shift_rows (line 380) | fn shift_rows(block: &mut [Byte], mode: AesMode) {
  function mix_column (line 394) | fn mix_column(block: &mut [Byte], mode: AesMode) {
  function transpose_block (line 426) | fn transpose_block(block: &mut [u8]) {
  function bytes_to_word (line 436) | fn bytes_to_word(bytes: &[Byte]) -> Word {
  function word_to_bytes (line 445) | fn word_to_bytes(word: Word) -> AesWord {
  function rot_word (line 454) | fn rot_word(word: Word) -> Word {
  function test_aes_128 (line 469) | fn test_aes_128() {
  function test_aes_192 (line 489) | fn test_aes_192() {
  function test_aes_256 (line 509) | fn test_aes_256() {
  function test_str (line 530) | fn test_str() {

FILE: src/ciphers/affine_cipher.rs
  constant SYMBOLS (line 30) | const SYMBOLS: &str = r##" !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLM...
  function gcd (line 42) | fn gcd(mut a: usize, mut b: usize) -> usize {
  function find_mod_inverse (line 64) | fn find_mod_inverse(a: i64, m: i64) -> Option<i64> {
  function check_keys (line 106) | fn check_keys(key_a: usize, key_b: usize, is_encrypt: bool) -> Result<()...
  function affine_encrypt (line 160) | pub fn affine_encrypt(key: usize, message: &str) -> Result<String, Strin...
  function affine_decrypt (line 201) | pub fn affine_decrypt(key: usize, message: &str) -> Result<String, Strin...
  function affine_generate_key (line 246) | pub fn affine_generate_key() -> usize {
  function test_gcd (line 266) | fn test_gcd() {
  function test_find_mod_inverse (line 276) | fn test_find_mod_inverse() {
  function test_encrypt_decrypt_example (line 284) | fn test_encrypt_decrypt_example() {
  function test_encrypt_simple (line 299) | fn test_encrypt_simple() {
  function test_roundtrip_various_messages (line 313) | fn test_roundtrip_various_messages() {
  function test_empty_string (line 331) | fn test_empty_string() {
  function test_invalid_key_a_is_one (line 341) | fn test_invalid_key_a_is_one() {
  function test_invalid_key_b_is_zero (line 351) | fn test_invalid_key_b_is_zero() {
  function test_invalid_key_not_coprime (line 361) | fn test_invalid_key_not_coprime() {
  function test_key_b_too_large (line 372) | fn test_key_b_too_large() {
  function test_symbols_not_in_set (line 384) | fn test_symbols_not_in_set() {
  function test_generate_key (line 398) | fn test_generate_key() {
  function test_generate_key_validity (line 409) | fn test_generate_key_validity() {
  function test_all_symbols (line 426) | fn test_all_symbols() {
  function test_different_keys_produce_different_ciphertexts (line 439) | fn test_different_keys_produce_different_ciphertexts() {
  function test_long_message (line 451) | fn test_long_message() {

FILE: src/ciphers/another_rot13.rs
  function another_rot13 (line 1) | pub fn another_rot13(text: &str) -> String {
  function test_simple (line 18) | fn test_simple() {
  function test_every_alphabet_with_space (line 23) | fn test_every_alphabet_with_space() {
  function test_non_alphabet (line 31) | fn test_non_alphabet() {

FILE: src/ciphers/baconian_cipher.rs
  function baconian_encode (line 8) | pub fn baconian_encode(message: &str) -> String {
  function baconian_decode (line 29) | pub fn baconian_decode(encoded: &str) -> String {
  function test_baconian_encoding (line 58) | fn test_baconian_encoding() {
  function test_baconian_decoding (line 65) | fn test_baconian_decoding() {

FILE: src/ciphers/base16.rs
  function base16_encode (line 31) | pub fn base16_encode(data: &[u8]) -> String {
  function base16_decode (line 78) | pub fn base16_decode(data: &str) -> Result<Vec<u8>, String> {
  function test_encode_hello_world (line 119) | fn test_encode_hello_world() {
  function test_encode_hello_world_uppercase (line 124) | fn test_encode_hello_world_uppercase() {
  function test_encode_empty (line 129) | fn test_encode_empty() {
  function test_encode_special_characters (line 134) | fn test_encode_special_characters() {
  function test_encode_all_bytes (line 139) | fn test_encode_all_bytes() {
  function test_decode_hello_world (line 146) | fn test_decode_hello_world() {
  function test_decode_hello_world_uppercase (line 154) | fn test_decode_hello_world_uppercase() {
  function test_decode_empty (line 162) | fn test_decode_empty() {
  function test_decode_special_characters (line 167) | fn test_decode_special_characters() {
  function test_decode_odd_length (line 172) | fn test_decode_odd_length() {
  function test_decode_lowercase_hex (line 181) | fn test_decode_lowercase_hex() {
  function test_decode_invalid_characters (line 190) | fn test_decode_invalid_characters() {
  function test_decode_mixed_case (line 199) | fn test_decode_mixed_case() {
  function test_roundtrip (line 205) | fn test_roundtrip() {
  function test_roundtrip_all_bytes (line 213) | fn test_roundtrip_all_bytes() {
  function test_roundtrip_empty (line 221) | fn test_roundtrip_empty() {

FILE: src/ciphers/base32.rs
  constant B32_CHARSET (line 9) | const B32_CHARSET: &[u8; 32] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
  function base32_encode (line 32) | pub fn base32_encode(data: &[u8]) -> Vec<u8> {
  function base32_decode (line 93) | pub fn base32_decode(data: &[u8]) -> Result<Vec<u8>, String> {
  function test_encode_hello_world (line 136) | fn test_encode_hello_world() {
  function test_encode_numbers (line 141) | fn test_encode_numbers() {
  function test_encode_long_string (line 146) | fn test_encode_long_string() {
  function test_encode_empty (line 154) | fn test_encode_empty() {
  function test_encode_single_char (line 159) | fn test_encode_single_char() {
  function test_decode_hello_world (line 164) | fn test_decode_hello_world() {
  function test_decode_numbers (line 172) | fn test_decode_numbers() {
  function test_decode_long_string (line 177) | fn test_decode_long_string() {
  function test_decode_empty (line 185) | fn test_decode_empty() {
  function test_decode_single_char (line 190) | fn test_decode_single_char() {
  function test_decode_without_padding (line 195) | fn test_decode_without_padding() {
  function test_decode_invalid_character (line 203) | fn test_decode_invalid_character() {
  function test_roundtrip_hello (line 210) | fn test_roundtrip_hello() {
  function test_roundtrip_various_strings (line 218) | fn test_roundtrip_various_strings() {
  function test_all_charset_characters (line 238) | fn test_all_charset_characters() {
  function test_binary_data (line 249) | fn test_binary_data() {
  function test_padding_variations (line 257) | fn test_padding_variations() {

FILE: src/ciphers/base64.rs
  constant CHARSET (line 7) | const CHARSET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq...
  constant PADDING (line 8) | const PADDING: char = '=';
  function collect_six_bits (line 29) | fn collect_six_bits(from: (u8, u8), offset: u8) -> u8 {
  function base64_encode (line 34) | pub fn base64_encode(data: &[u8]) -> String {
  function base64_decode (line 64) | pub fn base64_decode(data: &str) -> Result<Vec<u8>, (&str, u8)> {
  function pregenerated_random_bytes_encode (line 104) | fn pregenerated_random_bytes_encode() {
  function pregenerated_random_bytes_decode (line 170) | fn pregenerated_random_bytes_decode() {
  function encode_decode (line 239) | fn encode_decode() {
  function decode_encode (line 259) | fn decode_encode() {

FILE: src/ciphers/base85.rs
  function base10_to_85 (line 10) | fn base10_to_85(mut d: u32) -> String {
  function base85_to_10 (line 24) | fn base85_to_10(digits: &[u8]) -> u32 {
  function base85_encode (line 49) | pub fn base85_encode(data: &[u8]) -> Vec<u8> {
  function base85_decode (line 111) | pub fn base85_decode(data: &[u8]) -> Vec<u8> {
  function test_encode_empty (line 169) | fn test_encode_empty() {
  function test_encode_12345 (line 174) | fn test_encode_12345() {
  function test_encode_base85 (line 179) | fn test_encode_base85() {
  function test_decode_empty (line 184) | fn test_decode_empty() {
  function test_decode_12345 (line 189) | fn test_decode_12345() {
  function test_decode_base85 (line 194) | fn test_decode_base85() {
  function test_encode_decode_roundtrip (line 199) | fn test_encode_decode_roundtrip() {

FILE: src/ciphers/blake2b.rs
  type Word (line 6) | type Word = u64;
  constant BB (line 8) | const BB: usize = 128;
  constant U64BYTES (line 10) | const U64BYTES: usize = (u64::BITS as usize) / 8;
  type Block (line 12) | type Block = [Word; BB / U64BYTES];
  constant KK_MAX (line 14) | const KK_MAX: usize = 64;
  constant NN_MAX (line 15) | const NN_MAX: u8 = 64;
  constant RC (line 18) | const RC: [u32; 4] = [32, 24, 16, 63];
  constant IV (line 21) | const IV: [Word; 8] = [
  constant SIGMA (line 32) | const SIGMA: [[usize; 16]; 10] = [
  function blank_block (line 46) | const fn blank_block() -> Block {
  function add (line 52) | fn add(a: &mut Word, b: Word) {
  function ceil (line 57) | const fn ceil(dividend: usize, divisor: usize) -> usize {
  function g (line 61) | fn g(v: &mut [Word; 16], a: usize, b: usize, c: usize, d: usize, x: Word...
  function f (line 76) | fn f(h: &mut [Word; 8], m: Block, t: u128, flag: bool) {
  function blake2 (line 139) | fn blake2(d: Vec<Block>, ll: u128, kk: Word, nn: Word) -> Vec<u8> {
  function bytes_to_word (line 166) | fn bytes_to_word(bytes: &[u8]) -> Word {
  function blake2b (line 179) | pub fn blake2b(m: &[u8], k: &[u8], nn: u8) -> Vec<u8> {

FILE: src/ciphers/caesar.rs
  constant ERROR_MESSAGE (line 1) | const ERROR_MESSAGE: &str = "Rotation must be in the range [0, 25]";
  constant ALPHABET_LENGTH (line 2) | const ALPHABET_LENGTH: u8 = b'z' - b'a' + 1;
  function caesar (line 24) | pub fn caesar(text: &str, rotation: isize) -> Result<String, &'static st...
  function shift_char (line 53) | fn shift_char(c: char, rotation: isize) -> char {
  function alphabet_length_should_be_26 (line 92) | fn alphabet_length_should_be_26() {

FILE: src/ciphers/chacha.rs
  constant C (line 16) | pub const C: [u32; 4] = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];
  function chacha20 (line 86) | pub fn chacha20(input: &[u32; 16], output: &mut [u32; 16]) {
  function output_hex (line 111) | fn output_hex(inp: &[u32; 16]) -> String {
  function basic_tv1 (line 122) | fn basic_tv1() {

FILE: src/ciphers/diffie_hellman.rs
  function rand (line 198) | fn rand() -> usize {
  type DiffieHellman (line 205) | pub struct DiffieHellman {
    method new (line 230) | pub fn new(group: Option<u8>) -> Self {
    method get_private_key (line 249) | pub fn get_private_key(&self) -> String {
    method generate_public_key (line 254) | pub fn generate_public_key(&mut self) -> String {
    method is_valid_public_key (line 259) | pub fn is_valid_public_key(&self, key_str: &str) -> bool {
    method generate_shared_key (line 280) | pub fn generate_shared_key(self, other_key_str: &str) -> Option<String> {
  function verify_invalid_pub_key (line 297) | fn verify_invalid_pub_key() {
  function verify_valid_pub_key (line 303) | fn verify_valid_pub_key() {
  function verify_invalid_pub_key_same_as_prime (line 309) | fn verify_invalid_pub_key_same_as_prime() {
  function verify_key_exchange (line 327) | fn verify_key_exchange() {

FILE: src/ciphers/hashing_traits.rs
  type Hasher (line 1) | pub trait Hasher<const DIGEST_BYTES: usize> {
    method new_default (line 3) | fn new_default() -> Self;
    method update (line 6) | fn update(&mut self, data: &[u8]);
    method get_hash (line 11) | fn get_hash(&mut self) -> [u8; DIGEST_BYTES];
  type HMAC (line 15) | pub struct HMAC<const KEY_BYTES: usize, const DIGEST_BYTES: usize, H: Ha...
  function new_default (line 23) | pub fn new_default() -> Self {
  function add_key (line 34) | pub fn add_key(&mut self, key: &[u8]) -> Result<(), &'static str> {
  function update (line 59) | pub fn update(&mut self, data: &[u8]) {
  function finalize (line 63) | pub fn finalize(&mut self) -> [u8; DIGEST_BYTES] {
  function sha256_basic (line 77) | fn sha256_basic() {

FILE: src/ciphers/hill_cipher.rs
  constant KEY_STRING (line 32) | const KEY_STRING: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  constant MODULUS (line 33) | const MODULUS: i32 = 36;
  type HillCipher (line 36) | pub struct HillCipher {
    method new (line 51) | pub fn new(mut encrypt_key: Vec<Vec<i32>>) -> Result<Self, String> {
    method replace_letter (line 82) | fn replace_letter(&self, letter: char) -> Option<usize> {
    method replace_digit (line 86) | fn replace_digit(&self, num: i32) -> char {
    method determinant (line 90) | fn determinant(matrix: &[Vec<i32>]) -> i32 {
    method get_minor (line 111) | fn get_minor(matrix: &[Vec<i32>], row: usize, col: usize) -> Vec<Vec<i...
    method cofactor_matrix (line 126) | fn cofactor_matrix(matrix: &[Vec<i32>]) -> Vec<Vec<i32>> {
    method transpose (line 141) | fn transpose(matrix: &[Vec<i32>]) -> Vec<Vec<i32>> {
    method mod_inverse (line 154) | fn mod_inverse(a: i32, m: i32) -> Option<i32> {
    method gcd (line 159) | fn gcd(mut a: i32, mut b: i32) -> i32 {
    method check_determinant (line 172) | fn check_determinant(&self) -> Result<(), String> {
    method process_text (line 185) | fn process_text(&self, text: &str) -> String {
    method encrypt (line 205) | pub fn encrypt(&self, text: &str) -> String {
    method make_decrypt_key (line 233) | fn make_decrypt_key(&self) -> Vec<Vec<i32>> {
    method decrypt (line 255) | pub fn decrypt(&self, text: &str) -> String {
  function test_encrypt (line 290) | fn test_encrypt() {
  function test_decrypt (line 298) | fn test_decrypt() {
  function test_encrypt_decrypt_roundtrip (line 306) | fn test_encrypt_decrypt_roundtrip() {
  function test_process_text (line 318) | fn test_process_text() {
  function test_replace_letter (line 329) | fn test_replace_letter() {
  function test_replace_digit (line 338) | fn test_replace_digit() {
  function test_invalid_determinant (line 347) | fn test_invalid_determinant() {
  function test_3x3_matrix (line 354) | fn test_3x3_matrix() {
  function test_gcd (line 364) | fn test_gcd() {
  function test_mod_inverse (line 371) | fn test_mod_inverse() {

FILE: src/ciphers/kernighan.rs
  function kernighan (line 1) | pub fn kernighan(n: u32) -> i32 {
  function count_set_bits (line 18) | fn count_set_bits() {

FILE: src/ciphers/morse_code.rs
  constant UNKNOWN_CHARACTER (line 4) | const UNKNOWN_CHARACTER: &str = "........";
  constant _UNKNOWN_MORSE_CHARACTER (line 5) | const _UNKNOWN_MORSE_CHARACTER: &str = "_";
  function encode (line 7) | pub fn encode(message: &str) -> String {
  function _morse_dictionary (line 25) | fn _morse_dictionary() -> HashMap<&'static str, &'static str> {
  function _morse_to_alphanumeric_dictionary (line 51) | fn _morse_to_alphanumeric_dictionary() -> HashMap<&'static str, &'static...
  function _check_part (line 77) | fn _check_part(string: &str) -> bool {
  function _check_all_parts (line 87) | fn _check_all_parts(string: &str) -> bool {
  function _decode_token (line 91) | fn _decode_token(string: &str) -> String {
  function _decode_part (line 98) | fn _decode_part(string: &str) -> String {
  function decode (line 106) | pub fn decode(string: &str) -> Result<String, io::Error> {
  function encrypt_only_letters (line 128) | fn encrypt_only_letters() {
  function encrypt_letters_and_special_characters (line 138) | fn encrypt_letters_and_special_characters() {
  function encrypt_message_with_unsupported_character (line 148) | fn encrypt_message_with_unsupported_character() {
  function decrypt_valid_morsecode_with_spaces (line 158) | fn decrypt_valid_morsecode_with_spaces() {
  function decrypt_valid_character_set_invalid_morsecode (line 169) | fn decrypt_valid_character_set_invalid_morsecode() {
  function decrypt_invalid_morsecode_with_spaces (line 181) | fn decrypt_invalid_morsecode_with_spaces() {

FILE: src/ciphers/polybius.rs
  function encode_ascii (line 3) | pub fn encode_ascii(string: &str) -> String {
  function decode_ascii (line 41) | pub fn decode_ascii(string: &str) -> String {
  function encode_empty (line 89) | fn encode_empty() {
  function encode_valid_string (line 94) | fn encode_valid_string() {
  function encode_emoji (line 99) | fn encode_emoji() {
  function decode_empty (line 104) | fn decode_empty() {
  function decode_valid_string (line 109) | fn decode_valid_string() {
  function decode_emoji (line 117) | fn decode_emoji() {
  function decode_string_with_whitespace (line 122) | fn decode_string_with_whitespace() {
  function decode_unknown_string (line 130) | fn decode_unknown_string() {
  function decode_odd_length (line 135) | fn decode_odd_length() {
  function encode_and_decode (line 140) | fn encode_and_decode() {

FILE: src/ciphers/rail_fence.rs
  function rail_fence_encrypt (line 2) | pub fn rail_fence_encrypt(plain_text: &str, key: usize) -> String {
  function rail_fence_decrypt (line 12) | pub fn rail_fence_decrypt(cipher: &str, key: usize) -> String {
  function zigzag (line 26) | fn zigzag(n: usize) -> impl Iterator<Item = usize> {
  function rails_basic (line 34) | fn rails_basic() {

FILE: src/ciphers/rot13.rs
  function rot13 (line 1) | pub fn rot13(text: &str) -> String {
  function test_single_letter (line 18) | fn test_single_letter() {
  function test_bunch_of_letters (line 23) | fn test_bunch_of_letters() {
  function test_non_ascii (line 28) | fn test_non_ascii() {
  function test_twice (line 33) | fn test_twice() {

FILE: src/ciphers/rsa_cipher.rs
  type PublicKey (line 25) | pub struct PublicKey {
  type PrivateKey (line 32) | pub struct PrivateKey {
  function gcd (line 47) | fn gcd(mut a: u64, mut b: u64) -> u64 {
  function mod_inverse (line 68) | fn mod_inverse(a: i64, m: i64) -> Option<u64> {
  function mod_pow (line 102) | fn mod_pow(mut base: u64, mut exp: u64, modulus: u64) -> u64 {
  function generate_keypair (line 148) | pub fn generate_keypair(p: u64, q: u64) -> (PublicKey, PrivateKey) {
  function encrypt (line 192) | pub fn encrypt(message: u64, public_key: &PublicKey) -> u64 {
  function decrypt (line 218) | pub fn decrypt(ciphertext: u64, private_key: &PrivateKey) -> u64 {
  function encrypt_text (line 243) | pub fn encrypt_text(message: &str, public_key: &PublicKey) -> Vec<u64> {
  function decrypt_text (line 271) | pub fn decrypt_text(ciphertext: &[u64], private_key: &PrivateKey) -> Str...
  function test_gcd (line 286) | fn test_gcd() {
  function test_mod_inverse (line 294) | fn test_mod_inverse() {
  function test_mod_pow (line 301) | fn test_mod_pow() {
  function test_generate_keypair (line 308) | fn test_generate_keypair() {
  function test_encrypt_decrypt_number (line 324) | fn test_encrypt_decrypt_number() {
  function test_encrypt_decrypt_various_numbers (line 337) | fn test_encrypt_decrypt_various_numbers() {
  function test_encrypt_decrypt_text (line 348) | fn test_encrypt_decrypt_text() {
  function test_encrypt_decrypt_longer_text (line 359) | fn test_encrypt_decrypt_longer_text() {
  function test_different_primes (line 370) | fn test_different_primes() {
  function test_encrypt_decrypt_alphabet (line 381) | fn test_encrypt_decrypt_alphabet() {
  function test_key_properties (line 392) | fn test_key_properties() {

FILE: src/ciphers/salsa.rs
  function salsa20 (line 61) | pub fn salsa20(input: &[u32; 16], output: &mut [u32; 16]) {
  constant C (line 86) | const C: [u32; 4] = [0x65787061, 0x6e642033, 0x322d6279, 0x7465206b];
  function output_hex (line 88) | fn output_hex(inp: &[u32; 16]) -> String {
  function basic_tv1 (line 98) | fn basic_tv1() {

FILE: src/ciphers/sha256.rs
  constant H0 (line 9) | pub const H0: [u32; 8] = [
  constant K (line 13) | pub const K: [u32; 64] = [
  function ch (line 26) | fn ch(x: u32, y: u32, z: u32) -> u32 {
  function maj (line 31) | fn maj(x: u32, y: u32, z: u32) -> u32 {
  function bsig0 (line 36) | fn bsig0(x: u32) -> u32 {
  function bsig1 (line 41) | fn bsig1(x: u32) -> u32 {
  function ssig0 (line 46) | fn ssig0(x: u32) -> u32 {
  function ssig1 (line 51) | fn ssig1(x: u32) -> u32 {
  type SHA256 (line 55) | pub struct SHA256 {
    method new_default (line 102) | pub fn new_default() -> Self {
    method process_block (line 113) | pub fn process_block(&mut self, buf: &[u32; 16]) {
    method update (line 118) | pub fn update(&mut self, data: &[u8]) {
    method get_hash (line 158) | pub fn get_hash(&mut self) -> [u8; 32] {
    method new_default (line 195) | fn new_default() -> Self {
    method update (line 199) | fn update(&mut self, data: &[u8]) {
    method get_hash (line 203) | fn get_hash(&mut self) -> [u8; 32] {
  function process_block (line 70) | fn process_block(h: &mut [u32; 8], w: &mut [u32; 64], round: &mut [u32; ...
  function get_hash_string (line 215) | pub fn get_hash_string(hash: &[u8; 32]) -> String {
  function test_constants (line 225) | fn test_constants() {
  function empty (line 258) | fn empty() {
  function ascii (line 271) | fn ascii() {
  function ascii_avalanche (line 285) | fn ascii_avalanche() {
  function long_ascii (line 307) | fn long_ascii() {
  function short_ascii (line 330) | fn short_ascii() {

FILE: src/ciphers/sha3.rs
  constant B (line 2) | const B: usize = 1600;
  constant W (line 4) | const W: usize = B / 25;
  constant L (line 5) | const L: usize = W.ilog2() as usize;
  constant U8BITS (line 7) | const U8BITS: usize = u8::BITS as usize;
  type PadFn (line 24) | type PadFn = fn(isize, isize) -> Vec<bool>;
  type SpongeFn (line 25) | type SpongeFn = fn(&[bool]) -> [bool; B];
  type State (line 27) | type State = [[[bool; W]; 5]; 5];
  function state_new (line 29) | fn state_new() -> State {
  function state_fill (line 33) | fn state_fill(dest: &mut State, bits: &[bool]) {
  function state_copy (line 43) | fn state_copy(dest: &mut State, src: &State) {
  function state_dump (line 49) | fn state_dump(state: &State) -> [bool; B] {
  function theta (line 63) | fn theta(state: &mut State) {
  function rho (line 95) | fn rho(state: &mut State) {
  function pi (line 122) | fn pi(state: &mut State) {
  function chi (line 132) | fn chi(state: &mut State) {
  function rc (line 143) | fn rc(t: u8) -> bool {
  function iota (line 174) | fn iota(state: &mut State, i_r: u8) {
  function rnd (line 186) | fn rnd(state: &mut State, i_r: u8) {
  function keccak_f (line 194) | fn keccak_f(bits: &[bool]) -> [bool; B] {
  function pad101 (line 207) | fn pad101(x: isize, m: isize) -> Vec<bool> {
  function sponge (line 226) | fn sponge(f: SpongeFn, pad: PadFn, r: usize, n: &[bool], d: usize) -> Ve...
  function keccak (line 252) | fn keccak(c: usize, n: &[bool], d: usize) -> Vec<bool> {
  function h2b (line 256) | fn h2b(h: &[u8], n: usize) -> Vec<bool> {
  function b2h (line 273) | fn b2h(s: &[bool]) -> Vec<u8> {

FILE: src/ciphers/tea.rs
  type TeaContext (line 3) | struct TeaContext {
    method new (line 9) | pub fn new(key: &[u64; 2]) -> TeaContext {
    method encrypt_block (line 16) | pub fn encrypt_block(&self, block: u64) -> u64 {
    method decrypt_block (line 31) | pub fn decrypt_block(&self, block: u64) -> u64 {
  function divide_u64 (line 48) | fn divide_u64(n: u64) -> (W<u32>, W<u32>) {
  function tea_encrypt (line 52) | pub fn tea_encrypt(plain: &[u8], key: &[u8]) -> Vec<u8> {
  function tea_decrypt (line 64) | pub fn tea_decrypt(cipher: &[u8], key: &[u8]) -> Vec<u8> {
  function to_block (line 77) | fn to_block(data: &[u8]) -> u64 {
  function from_block (line 88) | fn from_block(block: u64) -> [u8; 8] {
  function test_block_convert (line 106) | fn test_block_convert() {
  function test_tea_encrypt (line 119) | fn test_tea_encrypt() {
  function test_tea_encdec (line 133) | fn test_tea_encdec() {

FILE: src/ciphers/theoretical_rot13.rs
  function theoretical_rot13 (line 2) | pub fn theoretical_rot13(text: &str) -> String {
  function test_single_letter (line 26) | fn test_single_letter() {
  function test_bunch_of_letters (line 30) | fn test_bunch_of_letters() {
  function test_non_ascii (line 35) | fn test_non_ascii() {
  function test_twice (line 40) | fn test_twice() {

FILE: src/ciphers/transposition.rs
  function transposition (line 12) | pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String {
  function encrypt (line 62) | fn encrypt(mut msg: String, key_order: Vec<usize>) -> String {
  function decrypt (line 123) | fn decrypt(mut msg: String, key_order: Vec<usize>) -> String {
  function encryption (line 190) | fn encryption() {
  function decryption (line 216) | fn decryption() {
  function double_encryption (line 238) | fn double_encryption() {
  function double_decryption (line 264) | fn double_decryption() {

FILE: src/ciphers/trifid.rs
  type CharToNum (line 9) | type CharToNum = HashMap<char, String>;
  type NumToChar (line 10) | type NumToChar = HashMap<String, char>;
  type PrepareResult (line 11) | type PrepareResult = Result<(String, String, CharToNum, NumToChar), Stri...
  constant TRIGRAM_VALUES (line 13) | const TRIGRAM_VALUES: [&str; 27] = [
  function trifid_encrypt (line 26) | pub fn trifid_encrypt(message: &str, alphabet: &str, period: usize) -> R...
  function trifid_decrypt (line 57) | pub fn trifid_decrypt(message: &str, alphabet: &str, period: usize) -> R...
  function encrypt_part (line 90) | fn encrypt_part(message_part: &str, char_to_num: &CharToNum) -> String {
  function decrypt_part (line 109) | fn decrypt_part(message_part: &str, char_to_num: &CharToNum) -> (String,...
  function prepare (line 141) | fn prepare(message: &str, alphabet: &str) -> PrepareResult {
  constant DEFAULT_ALPHABET (line 177) | const DEFAULT_ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.";
  function test_encrypt_basic (line 180) | fn test_encrypt_basic() {
  function test_encrypt_empty (line 186) | fn test_encrypt_empty() {
  function test_encrypt_custom_alphabet (line 192) | fn test_encrypt_custom_alphabet() {
  function test_decrypt_basic (line 202) | fn test_decrypt_basic() {
  function test_decrypt_custom_alphabet (line 208) | fn test_decrypt_custom_alphabet() {
  function test_encrypt_decrypt_roundtrip (line 214) | fn test_encrypt_decrypt_roundtrip() {
  function test_invalid_alphabet_length (line 223) | fn test_invalid_alphabet_length() {
  function test_invalid_character_in_message (line 230) | fn test_invalid_character_in_message() {
  function test_encrypt_part (line 240) | fn test_encrypt_part() {
  function test_decrypt_part (line 251) | fn test_decrypt_part() {
  function test_decrypt_part_single_char (line 264) | fn test_decrypt_part_single_char() {
  function test_decrypt_part_empty (line 275) | fn test_decrypt_part_empty() {
  function test_decrypt_part_with_unmapped_chars (line 284) | fn test_decrypt_part_with_unmapped_chars() {

FILE: src/ciphers/vernam.rs
  function vernam_encrypt (line 40) | pub fn vernam_encrypt(plaintext: &str, key: &str) -> String {
  function vernam_decrypt (line 100) | pub fn vernam_decrypt(ciphertext: &str, key: &str) -> String {
  function test_encrypt_basic (line 140) | fn test_encrypt_basic() {
  function test_decrypt_basic (line 145) | fn test_decrypt_basic() {
  function test_encrypt_decrypt_roundtrip (line 150) | fn test_encrypt_decrypt_roundtrip() {
  function test_encrypt_decrypt_long_text (line 159) | fn test_encrypt_decrypt_long_text() {
  function test_lowercase_input (line 168) | fn test_lowercase_input() {
  function test_mixed_case_input (line 175) | fn test_mixed_case_input() {
  function test_single_character (line 181) | fn test_single_character() {
  function test_key_wrapping (line 187) | fn test_key_wrapping() {
  function test_alphabet_boundary (line 196) | fn test_alphabet_boundary() {
  function test_same_key_as_plaintext (line 203) | fn test_same_key_as_plaintext() {
  function test_with_spaces_and_numbers (line 210) | fn test_with_spaces_and_numbers() {
  function test_empty_key_encrypt (line 219) | fn test_empty_key_encrypt() {
  function test_empty_key_decrypt (line 225) | fn test_empty_key_decrypt() {
  function test_key_with_only_numbers (line 231) | fn test_key_with_only_numbers() {
  function test_empty_plaintext (line 236) | fn test_empty_plaintext() {
  function test_plaintext_with_only_numbers (line 241) | fn test_plaintext_with_only_numbers() {

FILE: src/ciphers/vigenere.rs
  function vigenere (line 10) | pub fn vigenere(plain_text: &str, key: &str) -> String {
  function empty (line 43) | fn empty() {
  function vigenere_base (line 48) | fn vigenere_base() {
  function vigenere_with_spaces (line 56) | fn vigenere_with_spaces() {
  function vigenere_unicode_and_numbers (line 67) | fn vigenere_unicode_and_numbers() {
  function vigenere_unicode_key (line 75) | fn vigenere_unicode_key() {
  function vigenere_empty_key (line 83) | fn vigenere_empty_key() {

FILE: src/ciphers/xor.rs
  function xor_bytes (line 1) | pub fn xor_bytes(text: &[u8], key: u8) -> Vec<u8> {
  function xor (line 5) | pub fn xor(text: &str, key: u8) -> Vec<u8> {
  function test_simple (line 14) | fn test_simple() {
  function test_every_alphabet_with_space (line 21) | fn test_every_alphabet_with_space() {
  function test_multi_byte (line 28) | fn test_multi_byte() {
  function test_zero_byte (line 36) | fn test_zero_byte() {
  function test_invalid_byte (line 44) | fn test_invalid_byte() {

FILE: src/compression/burrows_wheeler_transform.rs
  type BwtResult (line 17) | pub struct BwtResult {
  function all_rotations (line 43) | pub fn all_rotations(s: &str) -> Vec<String> {
  function bwt_transform (line 75) | pub fn bwt_transform(s: &str) -> BwtResult {
  function reverse_bwt (line 123) | pub fn reverse_bwt(bwt_string: &str, idx_original_string: usize) -> Stri...
  function test_all_rotations_banana (line 150) | fn test_all_rotations_banana() {
  function test_all_rotations_casa (line 163) | fn test_all_rotations_casa() {
  function test_all_rotations_panama (line 172) | fn test_all_rotations_panama() {
  function test_bwt_transform_banana (line 180) | fn test_bwt_transform_banana() {
  function test_bwt_transform_casa (line 187) | fn test_bwt_transform_casa() {
  function test_bwt_transform_panama (line 194) | fn test_bwt_transform_panama() {
  function test_bwt_transform_empty (line 202) | fn test_bwt_transform_empty() {
  function test_reverse_bwt_banana (line 207) | fn test_reverse_bwt_banana() {
  function test_reverse_bwt_casa (line 213) | fn test_reverse_bwt_casa() {
  function test_reverse_bwt_panama (line 219) | fn test_reverse_bwt_panama() {
  function test_reverse_bwt_empty_string (line 226) | fn test_reverse_bwt_empty_string() {
  function test_reverse_bwt_index_too_high (line 232) | fn test_reverse_bwt_index_too_high() {
  function test_bwt_roundtrip (line 237) | fn test_bwt_roundtrip() {
  function test_single_character (line 255) | fn test_single_character() {
  function test_repeated_characters (line 265) | fn test_repeated_characters() {

FILE: src/compression/huffman_encoding.rs
  type HuffmanNode (line 51) | enum HuffmanNode {
    method frequency (line 64) | fn frequency(&self) -> usize {
    method new_leaf (line 73) | fn new_leaf(character: char, frequency: usize) -> Self {
    method new_internal (line 81) | fn new_internal(left: HuffmanNode, right: HuffmanNode) -> Self {
  type HeapNode (line 93) | struct HeapNode(HuffmanNode);
  method cmp (line 96) | fn cmp(&self, other: &Self) -> Ordering {
  method partial_cmp (line 103) | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
  function build_frequency_map (line 117) | fn build_frequency_map(text: &str) -> HashMap<char, usize> {
  function build_huffman_tree (line 134) | fn build_huffman_tree(frequencies: HashMap<char, usize>) -> Option<Huffm...
  function generate_codes (line 167) | fn generate_codes(node: &HuffmanNode, code: String, codes: &mut HashMap<...
  function huffman_encode (line 208) | pub fn huffman_encode(text: &str) -> (String, HashMap<char, String>) {
  function huffman_decode (line 245) | pub fn huffman_decode(encoded: &str, codes: &HashMap<char, String>) -> S...
  function demonstrate_huffman_from_file (line 303) | pub fn demonstrate_huffman_from_file(file_path: &str) -> std::io::Result...
  function test_empty_string (line 398) | fn test_empty_string() {
  function test_single_character (line 405) | fn test_single_character() {
  function test_simple_string (line 412) | fn test_simple_string() {
  function test_encode_decode_roundtrip (line 427) | fn test_encode_decode_roundtrip() {
  function test_frequency_based_encoding (line 444) | fn test_frequency_based_encoding() {
  function test_compression_ratio (line 457) | fn test_compression_ratio() {
  function test_all_unique_characters (line 468) | fn test_all_unique_characters() {
  function test_build_frequency_map (line 481) | fn test_build_frequency_map() {
  function test_unicode_characters (line 490) | fn test_unicode_characters() {
  function test_demonstrate_huffman_from_file (line 498) | fn test_demonstrate_huffman_from_file() {
  function test_demonstrate_empty_file (line 517) | fn test_demonstrate_empty_file() {
  function main (line 539) | fn main() {

FILE: src/compression/lz77.rs
  type Token (line 43) | pub struct Token {
    method new (line 51) | pub fn new(offset: usize, length: usize, indicator: char) -> Self {
    method fmt (line 61) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  type LZ77Compressor (line 68) | pub struct LZ77Compressor {
    method new (line 91) | pub fn new(window_size: usize, lookahead_buffer_size: usize) -> Self {
    method compress (line 121) | pub fn compress(&self, text: &str) -> Vec<Token> {
    method decompress (line 177) | pub fn decompress(&self, tokens: &[Token]) -> String {
    method find_encoding_token (line 198) | fn find_encoding_token(&self, text: &str, search_buffer: &str) -> Token {
    method match_length_from_index (line 241) | fn match_length_from_index(
  method default (line 266) | fn default() -> Self {
  function test_token_display (line 276) | fn test_token_display() {
  function test_compress_ababcbababaa (line 282) | fn test_compress_ababcbababaa() {
  function test_compress_aacaacabcabaaac (line 298) | fn test_compress_aacaacabcabaaac() {
  function test_decompress_cabracadabrarrarrad (line 314) | fn test_decompress_cabracadabrarrarrad() {
  function test_decompress_ababcbababaa (line 332) | fn test_decompress_ababcbababaa() {
  function test_decompress_aacaacabcabaaac (line 347) | fn test_decompress_aacaacabcabaaac() {
  function test_round_trip_compression (line 362) | fn test_round_trip_compression() {
  function test_empty_search_buffer (line 381) | fn test_empty_search_buffer() {
  function test_empty_text_panics (line 389) | fn test_empty_text_panics() {
  function test_default_compressor (line 395) | fn test_default_compressor() {
  function test_invalid_buffer_sizes (line 405) | fn test_invalid_buffer_sizes() {
  function test_single_character (line 410) | fn test_single_character() {
  function test_repeated_pattern (line 419) | fn test_repeated_pattern() {

FILE: src/compression/move_to_front.rs
  function blank_char_table (line 3) | fn blank_char_table() -> Vec<char> {
  function move_to_front_encode (line 7) | pub fn move_to_front_encode(text: &str) -> Vec<u8> {
  function move_to_front_decode (line 22) | pub fn move_to_front_decode(encoded: &[u8]) -> String {

FILE: src/compression/run_length_encoding.rs
  function run_length_encode (line 3) | pub fn run_length_encode(text: &str) -> Vec<(char, i32)> {
  function run_length_decode (line 19) | pub fn run_length_decode(encoded: &[(char, i32)]) -> String {
  function test_run_length_decode (line 33) | fn test_run_length_decode() {
  function test_run_length_encode (line 43) | fn test_run_length_encode() {

FILE: src/conversions/binary_to_decimal.rs
  function binary_to_decimal (line 3) | pub fn binary_to_decimal(binary: &str) -> Option<u128> {
  function basic_binary_to_decimal (line 31) | fn basic_binary_to_decimal() {
  function big_binary_to_decimal (line 37) | fn big_binary_to_decimal() {
  function very_big_binary_to_decimal (line 54) | fn very_big_binary_to_decimal() {

FILE: src/conversions/binary_to_hexadecimal.rs
  function binary_to_hexadecimal (line 25) | pub fn binary_to_hexadecimal(binary_str: &str) -> String {
  function test_empty_string (line 80) | fn test_empty_string() {
  function test_invalid_binary (line 87) | fn test_invalid_binary() {
  function test_binary (line 94) | fn test_binary() {
  function test_padded_binary (line 101) | fn test_padded_binary() {

FILE: src/conversions/binary_to_octal.rs
  function binary_to_octal (line 7) | pub fn binary_to_octal(binary_str: &str) -> Result<String, &'static str> {
  function test_binary_to_octal (line 38) | fn test_binary_to_octal() {
  function test_invalid_input (line 46) | fn test_invalid_input() {

FILE: src/conversions/decimal_to_binary.rs
  function decimal_to_binary (line 1) | pub fn decimal_to_binary(base_num: u64) -> String {
  function converting_decimal_to_binary (line 22) | fn converting_decimal_to_binary() {

FILE: src/conversions/decimal_to_hexadecimal.rs
  function decimal_to_hexadecimal (line 1) | pub fn decimal_to_hexadecimal(base_num: u64) -> String {
  function test_zero (line 28) | fn test_zero() {
  function test_single_digit_decimal (line 33) | fn test_single_digit_decimal() {
  function test_single_digit_hexadecimal (line 38) | fn test_single_digit_hexadecimal() {
  function test_multiple_digit_hexadecimal (line 43) | fn test_multiple_digit_hexadecimal() {
  function test_big (line 48) | fn test_big() {
  function test_random (line 53) | fn test_random() {

FILE: src/conversions/decimal_to_octal.rs
  function decimal_to_octal (line 7) | pub fn decimal_to_octal(decimal_num: u64) -> String {
  function test_decimal_to_octal (line 30) | fn test_decimal_to_octal() {

FILE: src/conversions/energy.rs
  type EnergyUnit (line 13) | pub enum EnergyUnit {
    method to_joule (line 95) | fn to_joule(self, value: f64) -> f64 {
    method joule_to_unit (line 168) | fn joule_to_unit(self, joule: f64) -> f64 {
  function convert_energy (line 242) | pub fn convert_energy(value: f64, from: EnergyUnit, to: EnergyUnit) -> f...
  constant EPSILON (line 251) | const EPSILON: f64 = 1e-10;
  function approx_eq (line 253) | fn approx_eq(a: f64, b: f64) -> bool {
  function test_same_unit_conversion (line 258) | fn test_same_unit_conversion() {
  function test_joule_to_kilojoule (line 273) | fn test_joule_to_kilojoule() {
  function test_joule_to_megajoule (line 285) | fn test_joule_to_megajoule() {
  function test_joule_to_gigajoule (line 297) | fn test_joule_to_gigajoule() {
  function test_watt_second (line 305) | fn test_watt_second() {
  function test_watt_hour (line 313) | fn test_watt_hour() {
  function test_kilowatt_hour_conversions (line 319) | fn test_kilowatt_hour_conversions() {
  function test_newton_meter (line 331) | fn test_newton_meter() {
  function test_calorie_nutritional (line 339) | fn test_calorie_nutritional() {
  function test_electronvolt (line 354) | fn test_electronvolt() {
  function test_btu_conversions (line 360) | fn test_btu_conversions() {
  function test_foot_pound (line 369) | fn test_foot_pound() {
  function test_round_trip_conversions (line 375) | fn test_round_trip_conversions() {
  function test_megawatt_hour (line 401) | fn test_megawatt_hour() {
  function test_horsepower_hour (line 409) | fn test_horsepower_hour() {
  function test_therm (line 415) | fn test_therm() {
  function test_ton_explosives (line 423) | fn test_ton_explosives() {
  function test_kiloton (line 431) | fn test_kiloton() {
  function test_erg (line 439) | fn test_erg() {
  function test_small_si_units (line 451) | fn test_small_si_units() {
  function test_calorie_variants (line 467) | fn test_calorie_variants() {
  function test_food_energy (line 475) | fn test_food_energy() {
  function test_electricity_bill (line 486) | fn test_electricity_bill() {
  function test_zero_value (line 493) | fn test_zero_value() {
  function test_negative_value (line 501) | fn test_negative_value() {
  function test_large_value (line 509) | fn test_large_value() {
  function test_imperial_units (line 515) | fn test_imperial_units() {
  function test_electron_volt_variants (line 524) | fn test_electron_volt_variants() {
  function test_therm_variants (line 540) | fn test_therm_variants() {
  function test_explosive_yield (line 553) | fn test_explosive_yield() {
  function test_atomic_units (line 560) | fn test_atomic_units() {

FILE: src/conversions/hexadecimal_to_binary.rs
  function hexadecimal_to_binary (line 7) | pub fn hexadecimal_to_binary(hex_str: &str) -> Result<String, String> {
  function test_empty_string (line 42) | fn test_empty_string() {
  function test_hexadecimal (line 49) | fn test_hexadecimal() {
  function test_hexadecimal2 (line 55) | fn test_hexadecimal2() {
  function test_invalid_hexadecimal (line 62) | fn test_invalid_hexadecimal() {

FILE: src/conversions/hexadecimal_to_decimal.rs
  function hexadecimal_to_decimal (line 1) | pub fn hexadecimal_to_decimal(hexadecimal_str: &str) -> Result<u64, &'st...
  function test_hexadecimal_to_decimal_empty (line 23) | fn test_hexadecimal_to_decimal_empty() {
  function test_hexadecimal_to_decimal_invalid (line 28) | fn test_hexadecimal_to_decimal_invalid() {
  function test_hexadecimal_to_decimal_valid1 (line 40) | fn test_hexadecimal_to_decimal_valid1() {
  function test_hexadecimal_to_decimal_valid2 (line 48) | fn test_hexadecimal_to_decimal_valid2() {
  function test_hexadecimal_to_decimal_valid3 (line 56) | fn test_hexadecimal_to_decimal_valid3() {

FILE: src/conversions/hexadecimal_to_octal.rs
  function hexadecimal_to_octal (line 7) | pub fn hexadecimal_to_octal(hex_str: &str) -> Result<String, &'static st...
  function test_hexadecimal_to_octal (line 45) | fn test_hexadecimal_to_octal() {
  function test_invalid_input (line 53) | fn test_invalid_input() {

FILE: src/conversions/ipv4_conversion.rs
  type Ipv4Error (line 11) | pub enum Ipv4Error {
    method fmt (line 23) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    method from (line 36) | fn from(_: ParseIntError) -> Self {
  function ipv4_to_decimal (line 54) | pub fn ipv4_to_decimal(ipv4_address: &str) -> Result<u32, Ipv4Error> {
  function alt_ipv4_to_decimal (line 90) | pub fn alt_ipv4_to_decimal(ipv4_address: &str) -> Result<u32, Ipv4Error> {
  function decimal_to_ipv4 (line 123) | pub fn decimal_to_ipv4(decimal_ipv4: u32) -> Result<String, Ipv4Error> {
  function test_ipv4_to_decimal_valid (line 141) | fn test_ipv4_to_decimal_valid() {
  function test_ipv4_to_decimal_invalid_format (line 150) | fn test_ipv4_to_decimal_invalid_format() {
  function test_ipv4_to_decimal_invalid_octet (line 158) | fn test_ipv4_to_decimal_invalid_octet() {
  function test_ipv4_to_decimal_parse_error (line 174) | fn test_ipv4_to_decimal_parse_error() {
  function test_alt_ipv4_to_decimal_valid (line 180) | fn test_alt_ipv4_to_decimal_valid() {
  function test_alt_ipv4_to_decimal_invalid (line 188) | fn test_alt_ipv4_to_decimal_invalid() {
  function test_decimal_to_ipv4_valid (line 200) | fn test_decimal_to_ipv4_valid() {
  function test_round_trip_conversion (line 210) | fn test_round_trip_conversion() {
  function test_both_methods_agree (line 230) | fn test_both_methods_agree() {
  function test_edge_cases (line 248) | fn test_edge_cases() {

FILE: src/conversions/length_conversion.rs
  type LengthUnit (line 15) | pub enum LengthUnit {
  function unit_to_meter_multiplier (line 26) | fn unit_to_meter_multiplier(from: LengthUnit) -> f64 {
  function unit_to_meter (line 39) | fn unit_to_meter(input: f64, from: LengthUnit) -> f64 {
  function meter_to_unit (line 43) | fn meter_to_unit(input: f64, to: LengthUnit) -> f64 {
  function length_conversion (line 49) | pub fn length_conversion(input: f64, from: LengthUnit, to: LengthUnit) -...
  function zero_to_zero (line 61) | fn zero_to_zero() {
  function length_of_one_meter (line 74) | fn length_of_one_meter() {

FILE: src/conversions/octal_to_binary.rs
  function octal_to_binary (line 6) | pub fn octal_to_binary(octal_str: &str) -> Result<String, &'static str> {
  function test_empty_string (line 41) | fn test_empty_string() {
  function test_invalid_octal (line 48) | fn test_invalid_octal() {
  function test_valid_octal (line 55) | fn test_valid_octal() {

FILE: src/conversions/octal_to_decimal.rs
  function octal_to_decimal (line 7) | pub fn octal_to_decimal(octal_str: &str) -> Result<u64, &'static str> {
  function test_empty_string (line 27) | fn test_empty_string() {
  function test_invalid_octal (line 34) | fn test_invalid_octal() {
  function test_valid_octal (line 41) | fn test_valid_octal() {
  function test_valid_octal2 (line 48) | fn test_valid_octal2() {
  function test_valid_octal3 (line 55) | fn test_valid_octal3() {

FILE: src/conversions/octal_to_hexadecimal.rs
  function octal_to_hexadecimal (line 7) | pub fn octal_to_hexadecimal(octal_str: &str) -> Result<String, &'static ...
  function test_octal_to_hexadecimal (line 36) | fn test_octal_to_hexadecimal() {
  function test_invalid_input (line 44) | fn test_invalid_input() {

FILE: src/conversions/order_of_magnitude_conversion.rs
  type MetricLengthUnit (line 43) | pub enum MetricLengthUnit {
    method exponent (line 76) | pub fn exponent(&self) -> i32 {
    method symbol (line 100) | pub fn symbol(&self) -> &'static str {
    method fmt (line 163) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  type Err (line 116) | type Err = String;
  method from_str (line 141) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  function convert_metric_length (line 191) | pub fn convert_metric_length(value: f64, from: MetricLengthUnit, to: Met...
  function metric_length_conversion (line 232) | pub fn metric_length_conversion(value: f64, from_type: &str, to_type: &s...
  function test_unit_exponents (line 253) | fn test_unit_exponents() {
  function test_unit_symbols (line 266) | fn test_unit_symbols() {
  function test_from_str_full_names (line 279) | fn test_from_str_full_names() {
  function test_from_str_symbols (line 295) | fn test_from_str_symbols() {
  function test_from_str_case_insensitive (line 315) | fn test_from_str_case_insensitive() {
  function test_from_str_plurals (line 331) | fn test_from_str_plurals() {
  function test_from_str_british_spellings (line 343) | fn test_from_str_british_spellings() {
  function test_from_str_american_and_british_equivalent (line 394) | fn test_from_str_american_and_british_equivalent() {
  function test_from_str_invalid (line 403) | fn test_from_str_invalid() {
  function test_convert_length_meter_to_kilometer (line 410) | fn test_convert_length_meter_to_kilometer() {
  function test_convert_length_meter_to_megameter (line 417) | fn test_convert_length_meter_to_megameter() {
  function test_convert_length_gigameter_to_meter (line 424) | fn test_convert_length_gigameter_to_meter() {
  function test_convert_length_gigameter_to_terameter (line 431) | fn test_convert_length_gigameter_to_terameter() {
  function test_convert_length_petameter_to_terameter (line 441) | fn test_convert_length_petameter_to_terameter() {
  function test_convert_length_petameter_to_exameter (line 451) | fn test_convert_length_petameter_to_exameter() {
  function test_convert_length_terameter_to_zettameter (line 458) | fn test_convert_length_terameter_to_zettameter() {
  function test_convert_length_yottameter_to_zettameter (line 468) | fn test_convert_length_yottameter_to_zettameter() {
  function test_convert_length_same_unit (line 478) | fn test_convert_length_same_unit() {
  function test_length_conversion_str_basic (line 488) | fn test_length_conversion_str_basic() {
  function test_length_conversion_str_symbols (line 494) | fn test_length_conversion_str_symbols() {
  function test_length_conversion_str_case_insensitive (line 500) | fn test_length_conversion_str_case_insensitive() {
  function test_length_conversion_str_plurals (line 506) | fn test_length_conversion_str_plurals() {
  function test_length_conversion_str_british_spellings (line 512) | fn test_length_conversion_str_british_spellings() {
  function test_length_conversion_str_invalid_from (line 532) | fn test_length_conversion_str_invalid_from() {
  function test_length_conversion_str_invalid_to (line 539) | fn test_length_conversion_str_invalid_to() {
  function test_length_conversion_str_large_values (line 546) | fn test_length_conversion_str_large_values() {
  function test_length_conversion_str_small_values (line 552) | fn test_length_conversion_str_small_values() {
  function test_all_conversions_reversible (line 558) | fn test_all_conversions_reversible() {

FILE: src/conversions/pressure.rs
  type IntoPressureUnit (line 15) | pub trait IntoPressureUnit {
    method into_pressure_unit (line 16) | fn into_pressure_unit(self) -> Result<PressureUnit, String>;
    method into_pressure_unit (line 20) | fn into_pressure_unit(self) -> Result<PressureUnit, String> {
    method into_pressure_unit (line 26) | fn into_pressure_unit(self) -> Result<PressureUnit, String> {
    method into_pressure_unit (line 32) | fn into_pressure_unit(self) -> Result<PressureUnit, String> {
  type PressureUnit (line 39) | pub enum PressureUnit {
    method fmt (line 81) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    method to_pascal_factor (line 115) | fn to_pascal_factor(self) -> f64 {
    method supported_units (line 155) | pub fn supported_units() -> Vec<&'static str> {
  type Err (line 165) | type Err = String;
  method from_str (line 167) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  function convert_pressure (line 225) | pub fn convert_pressure<F, T>(value: f64, from_unit: F, to_unit: T) -> R...
  constant EPSILON (line 253) | const EPSILON: f64 = 1e-3;
  function approx_eq (line 255) | fn approx_eq(a: f64, b: f64) -> bool {
  function test_pressure_conversions (line 260) | fn test_pressure_conversions() {
  function test_additional_coverage (line 392) | fn test_additional_coverage() {

FILE: src/conversions/rectangular_to_polar.rs
  function rectangular_to_polar (line 19) | pub fn rectangular_to_polar(real: f64, imag: f64) -> (f64, f64) {
  function round_to_two_decimals (line 29) | fn round_to_two_decimals(value: f64) -> f64 {
  function test_rectangular_to_polar (line 38) | fn test_rectangular_to_polar() {

FILE: src/conversions/rgb_cmyk_conversion.rs
  function rgb_to_cmyk (line 15) | pub fn rgb_to_cmyk(rgb: (u8, u8, u8)) -> (u8, u8, u8, u8) {

FILE: src/conversions/rgb_hsv_conversion.rs
  type ColorError (line 17) | pub enum ColorError {
    method fmt (line 27) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  type Rgb (line 44) | pub struct Rgb {
    method new (line 52) | pub fn new(red: u8, green: u8, blue: u8) -> Self {
  type Hsv (line 59) | pub struct Hsv {
    method new (line 67) | pub fn new(hue: f64, saturation: f64, value: f64) -> Result<Self, Colo...
    method approximately_equal (line 90) | pub fn approximately_equal(&self, other: &Hsv) -> bool {
  function hsv_to_rgb (line 113) | pub fn hsv_to_rgb(hue: f64, saturation: f64, value: f64) -> Result<Rgb, ...
  function rgb_to_hsv (line 187) | pub fn rgb_to_hsv(red: u8, green: u8, blue: u8) -> Result<Hsv, ColorErro...
  function test_hsv_to_rgb_basic_colors (line 222) | fn test_hsv_to_rgb_basic_colors() {
  function test_hsv_to_rgb_intermediate_colors (line 246) | fn test_hsv_to_rgb_intermediate_colors() {
  function test_hsv_to_rgb_invalid_hue (line 256) | fn test_hsv_to_rgb_invalid_hue() {
  function test_hsv_to_rgb_invalid_saturation (line 268) | fn test_hsv_to_rgb_invalid_saturation() {
  function test_hsv_to_rgb_invalid_value (line 280) | fn test_hsv_to_rgb_invalid_value() {
  function test_rgb_to_hsv_basic_colors (line 292) | fn test_rgb_to_hsv_basic_colors() {
  function test_rgb_to_hsv_intermediate_colors (line 323) | fn test_rgb_to_hsv_intermediate_colors() {
  function test_round_trip_conversion (line 339) | fn test_round_trip_conversion() {
  function test_approximately_equal_hsv (line 365) | fn test_approximately_equal_hsv() {
  function test_hsv_new_validation (line 384) | fn test_hsv_new_validation() {
  function test_edge_cases (line 411) | fn test_edge_cases() {
  function test_rgb_struct (line 427) | fn test_rgb_struct() {

FILE: src/conversions/roman_numerals.rs
  constant ROMAN_NUMERALS (line 23) | const ROMAN_NUMERALS: [(u32, &str); 13] = [
  function roman_to_int (line 68) | pub fn roman_to_int(roman: &str) -> Result<u32, String> {
  function int_to_roman (line 146) | pub fn int_to_roman(mut number: u32) -> Result<String, String> {
  function char_to_value (line 183) | fn char_to_value(ch: char) -> u32 {
  function test_roman_to_int_basic (line 201) | fn test_roman_to_int_basic() {
  function test_roman_to_int_additive (line 212) | fn test_roman_to_int_additive() {
  function test_roman_to_int_subtractive (line 225) | fn test_roman_to_int_subtractive() {
  function test_roman_to_int_complex (line 235) | fn test_roman_to_int_complex() {
  function test_roman_to_int_case_insensitive (line 245) | fn test_roman_to_int_case_insensitive() {
  function test_roman_to_int_invalid_character (line 252) | fn test_roman_to_int_invalid_character() {
  function test_roman_to_int_empty (line 260) | fn test_roman_to_int_empty() {
  function test_int_to_roman_basic (line 265) | fn test_int_to_roman_basic() {
  function test_int_to_roman_additive (line 276) | fn test_int_to_roman_additive() {
  function test_int_to_roman_subtractive (line 289) | fn test_int_to_roman_subtractive() {
  function test_int_to_roman_complex (line 299) | fn test_int_to_roman_complex() {
  function test_int_to_roman_out_of_range (line 309) | fn test_int_to_roman_out_of_range() {
  function test_roundtrip_conversion (line 316) | fn test_roundtrip_conversion() {
  function test_all_examples_from_python (line 326) | fn test_all_examples_from_python() {
  function test_edge_cases (line 343) | fn test_edge_cases() {

FILE: src/conversions/speed.rs
  type SpeedUnit (line 16) | pub enum SpeedUnit {
    method fmt (line 34) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    method as_kmh_multiplier (line 49) | fn as_kmh_multiplier(self) -> f64 {
    method kmh_multiplier (line 62) | fn kmh_multiplier(self) -> f64 {
  function convert_speed (line 86) | pub fn convert_speed(speed: f64, from: SpeedUnit, to: SpeedUnit) -> f64 {
  function test_speed_conversion (line 97) | fn test_speed_conversion() {
  function test_display (line 221) | fn test_display() {

FILE: src/conversions/temperature.rs
  type TemperatureUnit (line 14) | pub enum TemperatureUnit {
    method to_kelvin (line 26) | fn to_kelvin(self, value: f64) -> f64 {
    method kelvin_to_unit (line 39) | fn kelvin_to_unit(self, kelvin: f64) -> f64 {
  function convert_temperature (line 53) | pub fn convert_temperature(value: f64, from: TemperatureUnit, to: Temper...
  constant EPSILON (line 62) | const EPSILON: f64 = 1e-10;
  function approx_eq (line 64) | fn approx_eq(a: f64, b: f64) -> bool {
  function test_celsius_conversions (line 69) | fn test_celsius_conversions() {
  function test_fahrenheit_conversions (line 105) | fn test_fahrenheit_conversions() {
  function test_kelvin_conversions (line 125) | fn test_kelvin_conversions() {
  function test_round_trip_conversions (line 141) | fn test_round_trip_conversions() {
  function test_special_temperatures (line 167) | fn test_special_temperatures() {
  function test_historical_scales (line 206) | fn test_historical_scales() {
  function test_same_unit_conversion (line 239) | fn test_same_unit_conversion() {

FILE: src/conversions/time.rs
  type TimeUnit (line 12) | pub enum TimeUnit {
    method to_seconds (line 24) | fn to_seconds(self) -> f64 {
    method from_str (line 37) | fn from_str(s: &str) -> Result<Self, String> {
  function convert_time (line 70) | pub fn convert_time(time_value: f64, unit_from: &str, unit_to: &str) -> ...
  function test_seconds_to_hours (line 93) | fn test_seconds_to_hours() {
  function test_case_insensitive (line 98) | fn test_case_insensitive() {
  function test_weeks_to_days (line 105) | fn test_weeks_to_days() {
  function test_hours_to_minutes (line 110) | fn test_hours_to_minutes() {
  function test_days_to_months (line 115) | fn test_days_to_months() {
  function test_months_to_years (line 120) | fn test_months_to_years() {
  function test_years_to_seconds (line 125) | fn test_years_to_seconds() {
  function test_negative_value (line 130) | fn test_negative_value() {
  function test_invalid_from_unit (line 140) | fn test_invalid_from_unit() {
  function test_invalid_to_unit (line 147) | fn test_invalid_to_unit() {
  function test_zero_value (line 154) | fn test_zero_value() {
  function test_same_unit (line 159) | fn test_same_unit() {

FILE: src/conversions/volume.rs
  type VolumeUnit (line 11) | pub enum VolumeUnit {
    method to_cubic_meters (line 64) | fn to_cubic_meters(self, value: f64) -> f64 {
    method cubic_meters_to_unit (line 118) | fn cubic_meters_to_unit(self, cubic_meters: f64) -> f64 {
  function convert_volume (line 185) | pub fn convert_volume(value: f64, from: VolumeUnit, to: VolumeUnit) -> f...
  constant EPSILON (line 194) | const EPSILON: f64 = 1e-9;
  function approx_eq (line 196) | fn approx_eq(a: f64, b: f64, tolerance: f64) -> bool {
  function test_volume_conversions (line 201) | fn test_volume_conversions() {
  function test_round_trip_conversions (line 465) | fn test_round_trip_conversions() {
  function test_same_unit_conversion (line 491) | fn test_same_unit_conversion() {

FILE: src/conversions/weight.rs
  type IntoWeightUnit (line 40) | pub trait IntoWeightUnit {
    method into_weight_unit (line 41) | fn into_weight_unit(self) -> Result<WeightUnit, String>;
    method into_weight_unit (line 45) | fn into_weight_unit(self) -> Result<WeightUnit, String> {
    method into_weight_unit (line 51) | fn into_weight_unit(self) -> Result<WeightUnit, String> {
    method into_weight_unit (line 57) | fn into_weight_unit(self) -> Result<WeightUnit, String> {
  type WeightUnit (line 64) | pub enum WeightUnit {
    method fmt (line 102) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    method to_kilogram_factor (line 145) | fn to_kilogram_factor(self) -> f64 {
    method supported_units (line 186) | pub fn supported_units() -> Vec<&'static str> {
  type Err (line 216) | type Err = String;
  method from_str (line 218) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  function convert_weight (line 287) | pub fn convert_weight<F, T>(value: f64, from_unit: F, to_unit: T) -> Res...
  constant EPSILON (line 315) | const EPSILON: f64 = 1e-6;
  function approx_eq (line 317) | fn approx_eq(a: f64, b: f64) -> bool {
  function test_kilogram_conversions (line 329) | fn test_kilogram_conversions() {
  function test_large_metric_conversions (line 378) | fn test_large_metric_conversions() {
  function test_gram_conversions (line 413) | fn test_gram_conversions() {
  function test_milligram_conversions (line 435) | fn test_milligram_conversions() {
  function test_small_metric_conversions (line 456) | fn test_small_metric_conversions() {
  function test_metric_ton_conversions (line 501) | fn test_metric_ton_conversions() {
  function test_long_ton_conversions (line 526) | fn test_long_ton_conversions() {
  function test_imperial_large_units (line 551) | fn test_imperial_large_units() {
  function test_short_ton_conversions (line 590) | fn test_short_ton_conversions() {
  function test_pound_conversions (line 615) | fn test_pound_conversions() {
  function test_stone_conversions (line 644) | fn test_stone_conversions() {
  function test_ounce_conversions (line 665) | fn test_ounce_conversions() {
  function test_small_imperial_units (line 690) | fn test_small_imperial_units() {
  function test_carat_conversions (line 725) | fn test_carat_conversions() {
  function test_troy_weight_system (line 746) | fn test_troy_weight_system() {
  function test_atomic_mass_unit_conversions (line 807) | fn test_atomic_mass_unit_conversions() {
  function test_using_enums (line 820) | fn test_using_enums() {
  function test_mixed_usage (line 833) | fn test_mixed_usage() {
  function test_invalid_units (line 846) | fn test_invalid_units() {
  function test_roundtrip_conversion (line 853) | fn test_roundtrip_conversion() {
  function test_string_ownership (line 862) | fn test_string_ownership() {
  function test_display_implementation (line 875) | fn test_display_implementation() {
  function test_alternative_names (line 903) | fn test_alternative_names() {

FILE: src/data_structures/avl_tree.rs
  type AVLNode (line 9) | struct AVLNode<T: Ord> {
  type AVLTree (line 21) | pub struct AVLTree<T: Ord> {
  type Side (line 28) | enum Side {
  function new (line 35) | pub fn new() -> AVLTree<T> {
  function contains (line 43) | pub fn contains(&self, value: &T) -> bool {
  function insert (line 58) | pub fn insert(&mut self, value: T) -> bool {
  function remove (line 69) | pub fn remove(&mut self, value: &T) -> bool {
  function len (line 78) | pub fn len(&self) -> usize {
  function is_empty (line 83) | pub fn is_empty(&self) -> bool {
  function node_iter (line 88) | fn node_iter(&self) -> NodeIter<'_, T> {
  function iter (line 103) | pub fn iter(&self) -> Iter<'_, T> {
  function insert (line 111) | fn insert<T: Ord>(tree: &mut Option<Box<AVLNode<T>>>, value: T) -> bool {
  function remove (line 134) | fn remove<T: Ord>(tree: &mut Option<Box<AVLNode<T>>>, value: &T) -> bool {
  function merge (line 158) | fn merge<T: Ord>(left: Box<AVLNode<T>>, right: Box<AVLNode<T>>) -> Box<A...
  function take_min (line 169) | fn take_min<T: Ord>(tree: &mut Option<Box<AVLNode<T>>>) -> Option<Box<AV...
  function child (line 189) | fn child(&self, side: Side) -> &Option<Box<AVLNode<T>>> {
  function child_mut (line 197) | fn child_mut(&mut self, side: Side) -> &mut Option<Box<AVLNode<T>>> {
  function height (line 205) | fn height(&self, side: Side) -> usize {
  function balance_factor (line 210) | fn balance_factor(&self) -> i8 {
  function update_height (line 220) | fn update_height(&mut self) {
  function rotate (line 225) | fn rotate(&mut self, side: Side) {
  function rebalance (line 237) | fn rebalance(&mut self) {
  method default (line 255) | fn default() -> Self {
  type Output (line 261) | type Output = Side;
  method not (line 263) | fn not(self) -> Self::Output {
  function from_iter (line 272) | fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
  type NodeIter (line 284) | struct NodeIter<'a, T: Ord> {
  type Item (line 289) | type Item = &'a AVLNode<T>;
  method next (line 291) | fn next(&mut self) -> Option<Self::Item> {
  type Iter (line 309) | pub struct Iter<'a, T: Ord> {
  type Item (line 314) | type Item = &'a T;
  method next (line 316) | fn next(&mut self) -> Option<&'a T> {
  function is_balanced (line 329) | fn is_balanced<T: Ord>(tree: &AVLTree<T>) -> bool {
  function len (line 335) | fn len() {
  function contains (line 341) | fn contains() {
  function insert (line 348) | fn insert() {
  function remove (line 357) | fn remove() {
  function sorted (line 366) | fn sorted() {
  function balanced (line 372) | fn balanced() {

FILE: src/data_structures/b_tree.rs
  type Node (line 5) | struct Node<T> {
  type BTree (line 10) | pub struct BTree<T> {
  type BTreeProps (line 17) | struct BTreeProps {
    method new (line 46) | fn new(degree: usize) -> Self {
    method is_maxed_out (line 54) | fn is_maxed_out<T: Ord + Copy>(&self, node: &Node<T>) -> bool {
    method split_child (line 61) | fn split_child<T: Ord + Copy + Default>(&self, parent: &mut Node<T>, c...
    method insert_non_full (line 82) | fn insert_non_full<T: Ord + Copy + Default>(&mut self, node: &mut Node...
    method traverse_node (line 103) | fn traverse_node<T: Ord + Debug>(node: &Node<T>, depth: usize) {
  function new (line 27) | fn new(degree: usize, _keys: Option<Vec<T>>, _children: Option<Vec<Node<...
  function is_leaf (line 40) | fn is_leaf(&self) -> bool {
  function new (line 123) | pub fn new(branch_factor: usize) -> Self {
  function insert (line 131) | pub fn insert(&mut self, key: T) {
  function traverse (line 142) | pub fn traverse(&self) {
  function search (line 147) | pub fn search(&self, key: T) -> bool {

FILE: src/data_structures/binary_search_tree.rs
  type BinarySearchTree (line 6) | pub struct BinarySearchTree<T>
  method default (line 19) | fn default() -> Self {
  function new (line 29) | pub fn new() -> BinarySearchTree<T> {
  function search (line 39) | pub fn search(&self, value: &T) -> bool {
  function iter (line 68) | pub fn iter(&self) -> impl Iterator<Item = &T> {
  function insert (line 73) | pub fn insert(&mut self, value: T) {
  function minimum (line 97) | pub fn minimum(&self) -> Option<&T> {
  function maximum (line 105) | pub fn maximum(&self) -> Option<&T> {
  function floor (line 113) | pub fn floor(&self, value: &T) -> Option<&T> {
  function ceil (line 145) | pub fn ceil(&self, value: &T) -> Option<&T> {
  type BinarySearchTreeIter (line 180) | struct BinarySearchTreeIter<'a, T>
  function new (line 191) | pub fn new(tree: &BinarySearchTree<T>) -> BinarySearchTreeIter<'_, T> {
  function stack_push_left (line 197) | fn stack_push_left(&mut self) {
  type Item (line 208) | type Item = &'a T;
  method next (line 210) | fn next(&mut self) -> Option<&'a T> {
  function prequel_memes_tree (line 228) | fn prequel_memes_tree() -> BinarySearchTree<&'static str> {
  function test_search (line 241) | fn test_search() {
  function test_maximum_and_minimum (line 256) | fn test_maximum_and_minimum() {
  function test_floor_and_ceil (line 278) | fn test_floor_and_ceil() {
  function test_iterator (line 322) | fn test_iterator() {

FILE: src/data_structures/fenwick_tree.rs
  type FenwickTree (line 8) | pub struct FenwickTree<T>
  type FenwickTreeError (line 19) | pub enum FenwickTreeError {
  function with_capacity (line 42) | pub fn with_capacity(capacity: usize) -> Self {
  function update (line 61) | pub fn update(&mut self, index: usize, value: T) -> Result<(), FenwickTr...
  function prefix_query (line 87) | pub fn prefix_query(&self, index: usize) -> Result<T, FenwickTreeError> {
  function range_query (line 115) | pub fn range_query(&self, left: usize, right: usize) -> Result<T, Fenwic...
  function point_query (line 143) | pub fn point_query(&self, index: usize) -> Result<T, FenwickTreeError> {
  function set (line 172) | pub fn set(&mut self, index: usize, value: T) -> Result<(), FenwickTreeE...
  function lowbit (line 194) | const fn lowbit(x: usize) -> usize {
  function test_fenwick_tree (line 203) | fn test_fenwick_tree() {

FILE: src/data_structures/floyds_algorithm.rs
  function detect_cycle (line 8) | pub fn detect_cycle<T>(linked_list: &LinkedList<T>) -> Option<usize> {
  function has_cycle (line 35) | pub fn has_cycle<T>(linked_list: &LinkedList<T>) -> bool {
  function test_detect_cycle_no_cycle (line 65) | fn test_detect_cycle_no_cycle() {
  function test_detect_cycle_with_cycle (line 77) | fn test_detect_cycle_with_cycle() {

FILE: src/data_structures/graph.rs
  type NodeNotInGraph (line 5) | pub struct NodeNotInGraph;
    method fmt (line 8) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type DirectedGraph (line 13) | pub struct DirectedGraph {
  type UndirectedGraph (line 31) | pub struct UndirectedGraph {
  type Graph (line 64) | pub trait Graph {
    method new (line 18) | fn new() -> DirectedGraph {
    method adjacency_table_mutable (line 23) | fn adjacency_table_mutable(&mut self) -> &mut HashMap<String, Vec<(Str...
    method adjacency_table (line 26) | fn adjacency_table(&self) -> &HashMap<String, Vec<(String, i32)>> {
    method new (line 36) | fn new() -> UndirectedGraph {
    method adjacency_table_mutable (line 41) | fn adjacency_table_mutable(&mut self) -> &mut HashMap<String, Vec<(Str...
    method adjacency_table (line 44) | fn adjacency_table(&self) -> &HashMap<String, Vec<(String, i32)>> {
    method add_edge (line 47) | fn add_edge(&mut self, edge: (&str, &str, i32)) {
    method new (line 65) | fn new() -> Self;
    method adjacency_table_mutable (line 66) | fn adjacency_table_mutable(&mut self) -> &mut HashMap<String, Vec<(Str...
    method adjacency_table (line 67) | fn adjacency_table(&self) -> &HashMap<String, Vec<(String, i32)>>;
    method add_node (line 69) | fn add_node(&mut self, node: &str) -> bool {
    method add_edge (line 80) | fn add_edge(&mut self, edge: (&str, &str, i32)) {
    method neighbours (line 91) | fn neighbours(&self, node: &str) -> Result<&Vec<(String, i32)>, NodeNo...
    method contains (line 98) | fn contains(&self, node: &str) -> bool {
    method nodes (line 102) | fn nodes(&self) -> HashSet<&String> {
    method edges (line 106) | fn edges(&self) -> Vec<(&String, &String, i32)> {
  function test_add_edge (line 122) | fn test_add_edge() {
  function test_neighbours (line 143) | fn test_neighbours() {
  function test_add_node (line 163) | fn test_add_node() {
  function test_add_edge (line 178) | fn test_add_edge() {
  function test_neighbours (line 196) | fn test_neighbours() {
  function test_contains (line 210) | fn test_contains() {

FILE: src/data_structures/hash_table.rs
  type HashTable (line 3) | pub struct HashTable<K, V> {
  method default (line 9) | fn default() -> Self {
  type Hashable (line 14) | pub trait Hashable {
    method hash (line 15) | fn hash(&self) -> usize;
    method hash (line 74) | fn hash(&self) -> usize {
  function new (line 19) | pub fn new() -> HashTable<K, V> {
  function insert (line 30) | pub fn insert(&mut self, key: K, value: V) {
  function search (line 39) | pub fn search(&self, key: K) -> Option<&V> {
  function resize (line 47) | fn resize(&mut self) {
  type TestKey (line 71) | struct TestKey(usize);
  function test_insert_and_search (line 80) | fn test_insert_and_search() {
  function test_resize (line 92) | fn test_resize() {
  function test_search_nonexistent (line 104) | fn test_search_nonexistent() {
  function test_multiple_inserts_and_searches (line 116) | fn test_multiple_inserts_and_searches() {
  function test_not_overwrite_existing_key (line 129) | fn test_not_overwrite_existing_key() {
  function test_empty_search (line 139) | fn test_empty_search() {

FILE: src/data_structures/heap.rs
  type Heap (line 17) | pub struct Heap<T> {
  function new (line 30) | pub fn new(comparator: fn(&T, &T) -> bool) -> Self {
  function from_vec (line 45) | pub fn from_vec(items: Vec<T>, comparator: fn(&T, &T) -> bool) -> Self {
  function build_heap (line 52) | fn build_heap(&mut self) {
  function len (line 63) | pub fn len(&self) -> usize {
  function is_empty (line 71) | pub fn is_empty(&self) -> bool {
  function add (line 79) | pub fn add(&mut self, value: T) {
  function pop (line 88) | pub fn pop(&mut self) -> Option<T> {
  function iter (line 103) | pub fn iter(&self) -> Iter<'_, T> {
  function heapify_up (line 111) | fn heapify_up(&mut self, mut idx: usize) {
  function heapify_down (line 126) | fn heapify_down(&mut self, mut idx: usize) {
  function parent_idx (line 158) | fn parent_idx(&self, idx: usize) -> Option<usize> {
  function children_present (line 173) | fn children_present(&self, idx: usize) -> bool {
  function left_child_idx (line 184) | fn left_child_idx(&self, idx: usize) -> usize {
  function right_child_idx (line 195) | fn right_child_idx(&self, idx: usize) -> usize {
  function new_min (line 208) | pub fn new_min() -> Heap<T> {
  function new_max (line 216) | pub fn new_max() -> Heap<T> {
  function from_vec_min (line 227) | pub fn from_vec_min(items: Vec<T>) -> Heap<T> {
  function from_vec_max (line 238) | pub fn from_vec_max(items: Vec<T>) -> Heap<T> {
  function test_empty_heap (line 248) | fn test_empty_heap() {
  function test_min_heap (line 254) | fn test_min_heap() {
  function test_max_heap (line 271) | fn test_max_heap() {
  function test_iter_heap (line 288) | fn test_iter_heap() {
  function test_from_vec_min (line 311) | fn test_from_vec_min() {
  function test_from_vec_max (line 323) | fn test_from_vec_max() {

FILE: src/data_structures/lazy_segment_tree.rs
  type LazySegmentTree (line 4) | pub struct LazySegmentTree<T: Debug + Default + Ord + Copy + Display + A...
  function from_vec (line 13) | pub fn from_vec(arr: &[T], merge: fn(T, T) -> T) -> Self {
  function build_recursive (line 27) | fn build_recursive(
  function query (line 44) | pub fn query(&mut self, range: Range<usize>) -> Option<T> {
  function query_recursive (line 48) | fn query_recursive(
  function update (line 74) | pub fn update(&mut self, target_range: Range<usize>, val: T) {
  function update_recursive (line 78) | fn update_recursive(
  function propagation (line 109) | fn propagation(&mut self, idx: usize, element_range: &Range<usize>, pare...
  function test_min_segments (line 133) | fn test_min_segments() {
  function test_max_segments (line 149) | fn test_max_segments() {
  function test_sum_segments (line 165) | fn test_sum_segments() {
  function test_update_segments_tiny (line 181) | fn test_update_segments_tiny() {
  function test_update_segments (line 194) | fn test_update_segments() {
  function check_overall_interval_min (line 217) | fn check_overall_interval_min(array: Vec<i32>) -> TestResult {
  function check_overall_interval_max (line 223) | fn check_overall_interval_max(array: Vec<i32>) -> TestResult {
  function check_overall_interval_sum (line 229) | fn check_overall_interval_sum(array: Vec<i32>) -> TestResult {
  function check_single_interval_min (line 235) | fn check_single_interval_min(array: Vec<i32>) -> TestResult {
  function check_single_interval_max (line 250) | fn check_single_interval_max(array: Vec<i32>) -> TestResult {
  function check_single_interval_sum (line 265) | fn check_single_interval_sum(array: Vec<i32>) -> TestResult {

FILE: src/data_structures/linked_list.rs
  type Node (line 5) | pub struct Node<T> {
  function new (line 12) | fn new(t: T) -> Node<T> {
  type LinkedList (line 21) | pub struct LinkedList<T> {
  method default (line 30) | fn default() -> Self {
  function new (line 36) | pub fn new() -> Self {
  function insert_at_head (line 45) | pub fn insert_at_head(&mut self, obj: T) {
  function insert_at_tail (line 58) | pub fn insert_at_tail(&mut self, obj: T) {
  function insert_at_ith (line 71) | pub fn insert_at_ith(&mut self, index: u32, obj: T) {
  function delete_head (line 111) | pub fn delete_head(&mut self) -> Option<T> {
  function delete_tail (line 131) | pub fn delete_tail(&mut self) -> Option<T> {
  function delete_ith (line 146) | pub fn delete_ith(&mut self, index: u32) -> Option<T> {
  function get (line 186) | pub fn get(&self, index: i32) -> Option<&T> {
  function get_ith_node (line 190) | fn get_ith_node(node: Option<NonNull<Node<T>>>, index: i32) -> Option<No...
  method drop (line 202) | fn drop(&mut self) {
  method fmt (line 212) | fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  method fmt (line 224) | fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  function insert_at_tail_works (line 239) | fn insert_at_tail_works() {
  function insert_at_head_works (line 251) | fn insert_at_head_works() {
  function insert_at_ith_can_add_to_tail (line 264) | fn insert_at_ith_can_add_to_tail() {
  function insert_at_ith_can_add_to_head (line 277) | fn insert_at_ith_can_add_to_head() {
  function insert_at_ith_can_add_to_middle (line 290) | fn insert_at_ith_can_add_to_middle() {
  function insert_at_ith_and_delete_at_ith_in_the_middle (line 310) | fn insert_at_ith_and_delete_at_ith_in_the_middle() {
  function insert_at_ith_and_delete_ith_work_over_many_iterations (line 340) | fn insert_at_ith_and_delete_ith_work_over_many_iterations() {
  function delete_tail_works (line 374) | fn delete_tail_works() {
  function delete_head_works (line 393) | fn delete_head_works() {
  function delete_ith_can_delete_at_tail (line 412) | fn delete_ith_can_delete_at_tail() {
  function delete_ith_can_delete_at_head (line 427) | fn delete_ith_can_delete_at_head() {
  function delete_ith_can_delete_in_middle (line 442) | fn delete_ith_can_delete_in_middle() {
  function create_numeric_list (line 462) | fn create_numeric_list() {
  function create_string_list (line 472) | fn create_string_list() {
  function get_by_index_in_numeric_list (line 482) | fn get_by_index_in_numeric_list() {
  function get_by_index_in_string_list (line 493) | fn get_by_index_in_string_list() {
  function delete_ith_panics_if_index_equals_length (line 505) | fn delete_ith_panics_if_index_equals_length() {

FILE: src/data_structures/probabilistic/bloom_filter.rs
  type BloomFilter (line 6) | pub trait BloomFilter<Item: Hash> {
    method insert (line 7) | fn insert(&mut self, item: Item);
    method contains (line 8) | fn contains(&self, item: &Item) -> bool;
  type BasicBloomFilter (line 26) | struct BasicBloomFilter<const CAPACITY: usize> {
  method default (line 31) | fn default() -> Self {
  function insert (line 39) | fn insert(&mut self, item: Item) {
  function contains (line 46) | fn contains(&self, item: &Item) -> bool {
  type SingleBinaryBloomFilter (line 65) | struct SingleBinaryBloomFilter {
    method insert (line 78) | fn insert(&mut self, item: T) {
    method contains (line 82) | fn contains(&self, item: &T) -> bool {
  function mask_128 (line 70) | fn mask_128<T: Hash>(hasher: &mut DefaultHasher, item: T) -> u128 {
  type MultiBinaryBloomFilter (line 104) | pub struct MultiBinaryBloomFilter {
    method with_dimensions (line 111) | pub fn with_dimensions(filter_size: usize, hash_count: usize) -> Self {
    method from_estimate (line 120) | pub fn from_estimate(
    method insert (line 137) | fn insert(&mut self, item: Item) {
    method contains (line 149) | fn contains(&self, item: &Item) -> bool {
  type TestSet (line 175) | struct TestSet {
  method arbitrary (line 181) | fn arbitrary(g: &mut Gen) -> Self {
  function basic_filter_must_not_return_false_negative (line 197) | fn basic_filter_must_not_return_false_negative(TestSet { to_insert, to_t...
  function binary_filter_must_not_return_false_negative (line 210) | fn binary_filter_must_not_return_false_negative(TestSet { to_insert, to_...
  function a_basic_filter_of_capacity_128_is_the_same_as_a_binary_filter (line 223) | fn a_basic_filter_of_capacity_128_is_the_same_as_a_binary_filter(
  constant FALSE_POSITIVE_MAX (line 241) | const FALSE_POSITIVE_MAX: f64 = 0.05;
  function a_multi_binary_bloom_filter_must_not_return_false_negatives (line 244) | fn a_multi_binary_bloom_filter_must_not_return_false_negatives(

FILE: src/data_structures/probabilistic/count_min_sketch.rs
  type CountMinSketch (line 17) | pub trait CountMinSketch {
    method increment (line 20) | fn increment(&mut self, item: Self::Item);
    method increment_by (line 21) | fn increment_by(&mut self, item: Self::Item, count: usize);
    method get_count (line 22) | fn get_count(&self, item: Self::Item) -> usize;
    type Item (line 122) | type Item = Item;
    method increment (line 124) | fn increment(&mut self, item: Self::Item) {
    method increment_by (line 128) | fn increment_by(&mut self, item: Self::Item, count: usize) {
    method get_count (line 138) | fn get_count(&self, item: Self::Item) -> usize {
  type HashCountMinSketch (line 91) | pub struct HashCountMinSketch<Item: Hash, const WIDTH: usize, const DEPT...
  method fmt (line 100) | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
  method default (line 108) | fn default() -> Self {
  function hash_functions_should_hash_differently (line 163) | fn hash_functions_should_hash_differently() {
  function inspect_counts (line 182) | fn inspect_counts() {
  type TestItem (line 205) | struct TestItem {
  constant MAX_STR_LEN (line 210) | const MAX_STR_LEN: u8 = 30;
  constant MAX_COUNT (line 211) | const MAX_COUNT: usize = 20;
  method arbitrary (line 214) | fn arbitrary(g: &mut Gen) -> Self {
  function must_not_understimate_count (line 226) | fn must_not_understimate_count(test_items: Vec<TestItem>) {

FILE: src/data_structures/queue.rs
  type Queue (line 9) | pub struct Queue<T> {
  function new (line 15) | pub fn new() -> Queue<T> {
  function enqueue (line 22) | pub fn enqueue(&mut self, value: T) {
  function dequeue (line 27) | pub fn dequeue(&mut self) -> Option<T> {
  function peek_front (line 32) | pub fn peek_front(&self) -> Option<&T> {
  function peek_back (line 37) | pub fn peek_back(&self) -> Option<&T> {
  function len (line 42) | pub fn len(&self) -> usize {
  function is_empty (line 47) | pub fn is_empty(&self) -> bool {
  function drain (line 52) | pub fn drain(&mut self) {
  method default (line 59) | fn default() -> Queue<T> {
  function test_queue_functionality (line 69) | fn test_queue_functionality() {

FILE: src/data_structures/range_minimum_query.rs
  type RangeError (line 16) | pub enum RangeError {
  type RangeMinimumQuery (line 24) | pub struct RangeMinimumQuery<T: PartialOrd + Copy> {
  function new (line 42) | pub fn new(input: &[T]) -> RangeMinimumQuery<T> {
  function get_range_min (line 61) | pub fn get_range_min(&self, start: usize, end: usize) -> Result<T, Range...
  function build_sparse_table (line 97) | fn build_sparse_table<T: PartialOrd>(data: &[T]) -> Vec<Vec<usize>> {
  function simple_query_tests (line 165) | fn simple_query_tests() {
  function float_query_tests (line 180) | fn float_query_tests() {

FILE: src/data_structures/rb_tree.rs
  type Color (line 7) | enum Color {
  type RBNode (line 12) | pub struct RBNode<K: Ord, V> {
  function new (line 22) | fn new(key: K, value: V) -> RBNode<K, V> {
  type RBTree (line 34) | pub struct RBTree<K: Ord, V> {
  method default (line 39) | fn default() -> Self {
  function new (line 45) | pub fn new() -> RBTree<K, V> {
  function find (line 49) | pub fn find(&self, key: &K) -> Option<&V> {
  function insert (line 63) | pub fn insert(&mut self, key: K, value: V) {
  function delete (line 91) | pub fn delete(&mut self, key: &K) {
  function iter (line 223) | pub fn iter<'a>(&self) -> RBTreeIterator<'a, K, V> {
  function insert_fixup (line 237) | unsafe fn insert_fixup<K: Ord, V>(tree: &mut RBTree<K, V>, mut node: *mu...
  function delete_fixup (line 362) | unsafe fn delete_fixup<K: Ord, V>(tree: &mut RBTree<K, V>, mut parent: *...
  function left_rotate (line 508) | unsafe fn left_rotate<K: Ord, V>(tree: &mut RBTree<K, V>, x: *mut RBNode...
  function right_rotate (line 543) | unsafe fn right_rotate<K: Ord, V>(tree: &mut RBTree<K, V>, x: *mut RBNod...
  function replace_node (line 578) | unsafe fn replace_node<K: Ord, V>(
  type RBTreeIterator (line 593) | pub struct RBTreeIterator<'a, K: Ord, V> {
  type Item (line 598) | type Item = &'a RBNode<K, V>;
  method next (line 599) | fn next(&mut self) -> Option<Self::Item> {
  function find (line 621) | fn find() {
  function insert (line 633) | fn insert() {
  function delete (line 643) | fn delete() {
  function delete_edge_case_null_pointer_guard (line 658) | fn delete_edge_case_null_pointer_guard() {

FILE: src/data_structures/segment_tree.rs
  type SegmentTreeError (line 10) | pub enum SegmentTreeError {
  type SegmentTree (line 19) | pub struct SegmentTree<T, F>
  function from_vec (line 47) | pub fn from_vec(arr: &[T], merge: F) -> Self {
  function query (line 76) | pub fn query(&self, range: Range<usize>) -> Result<Option<T>, SegmentTre...
  function update (line 119) | pub fn update(&mut self, idx: usize, val: T) -> Result<(), SegmentTreeEr...
  function test_min_segments (line 145) | fn test_min_segments() {
  function test_max_segments (line 172) | fn test_max_segments() {
  function test_sum_segments (line 199) | fn test_sum_segments() {

FILE: src/data_structures/segment_tree_recursive.rs
  type SegmentTreeError (line 6) | pub enum SegmentTreeError {
  type SegmentTree (line 15) | pub struct SegmentTree<T, F>
  function from_vec (line 43) | pub fn from_vec(arr: &[T], merge_fn: F) -> Self {
  function build_recursive (line 63) | fn build_recursive(&mut self, arr: &[T], node_idx: usize, node_range: Ra...
  function query (line 87) | pub fn query(&self, target_range: Range<usize>) -> Result<Option<T>, Seg...
  function query_recursive (line 106) | fn query_recursive(
  function update (line 140) | pub fn update(&mut self, target_idx: usize, val: T) -> Result<(), Segmen...
  function update_recursive (line 156) | fn update_recursive(
  function test_min_segments (line 184) | fn test_min_segments() {
  function test_max_segments (line 211) | fn test_max_segments() {
  function test_sum_segments (line 238) | fn test_sum_segments() {

FILE: src/data_structures/skip_list.rs
  type Node (line 4) | struct Node<K: Ord, V> {
  function new (line 11) | pub fn new() -> Self {
  function make_node (line 21) | pub fn make_node(capacity: usize, key: K, value: V) -> Self {
  type SkipList (line 35) | pub struct SkipList<K: Ord, V> {
  function new (line 43) | pub fn new(max_level: usize) -> Self {
  function search (line 56) | pub fn search(&self, searched_key: K) -> Option<&V> {
  function insert (line 95) | pub fn insert(&mut self, searched_key: K, new_value: V) -> bool {
  function delete (line 154) | pub fn delete(&mut self, searched_key: K) -> bool {
  function iter (line 228) | pub fn iter(&self) -> Iter<'_, K, V> {
  method drop (line 234) | fn drop(&mut self) {
  function random_value (line 246) | fn random_value(max: usize) -> usize {
  type Iter (line 258) | pub struct Iter<'a, K: Ord, V> {
  function new (line 264) | pub fn new(skip_list: &'a SkipList<K, V>) -> Self {
  type Item (line 273) | type Item = (&'a K, &'a V);
  method next (line 275) | fn next(&mut self) -> Option<Self::Item> {
  function insert_and_delete (line 295) | fn insert_and_delete() {
  function iterator (line 316) | fn iterator() {
  function cannot_search (line 327) | fn cannot_search() {
  function delete_unsuccessfully (line 344) | fn delete_unsuccessfully() {
  function update_value_with_insert_operation (line 361) | fn update_value_with_insert_operation() {

FILE: src/data_structures/stack_using_singly_linked_list.rs
  type Stack (line 2) | pub struct Stack<T> {
  type Link (line 6) | type Link<T> = Option<Box<Node<T>>>;
  type Node (line 8) | struct Node<T> {
  function new (line 16) | pub fn new() -> Self {
  function push (line 27) | pub fn push(&mut self, elem: T) {
  function pop (line 46) | pub fn pop(&mut self) -> Result<T, &str> {
  function is_empty (line 56) | pub fn is_empty(&self) -> bool {
  function peek (line 61) | pub fn peek(&self) -> Option<&T> {
  function peek_mut (line 69) | pub fn peek_mut(&mut self) -> Option<&mut T> {
  function into_iter_for_stack (line 76) | pub fn into_iter_for_stack(self) -> IntoIter<T> {
  function iter (line 79) | pub fn iter(&self) -> Iter<'_, T> {
  function iter_mut (line 85) | pub fn iter_mut(&mut self) -> IterMut<'_, T> {
  method default (line 93) | fn default() -> Self {
  method drop (line 110) | fn drop(&mut self) {
  type IntoIter (line 124) | pub struct IntoIter<T>(Stack<T>);
  type Item (line 128) | type Item = T;
  method next (line 130) | fn next(&mut self) -> Option<Self::Item> {
  type Iter (line 135) | pub struct Iter<'a, T> {
  type Item (line 140) | type Item = &'a T;
  method next (line 141) | fn next(&mut self) -> Option<Self::Item> {
  type IterMut (line 150) | pub struct IterMut<'a, T> {
  type Item (line 155) | type Item = &'a mut T;
  method next (line 156) | fn next(&mut self) -> Option<Self::Item> {
  function basics (line 171) | fn basics() {
  function peek (line 197) | fn peek() {
  function into_iter (line 217) | fn into_iter() {
  function iter (line 231) | fn iter() {
  function iter_mut (line 244) | fn iter_mut() {

FILE: src/data_structures/treap.rs
  type TreapNode (line 10) | struct TreapNode<T: Ord> {
  type Treap (line 22) | pub struct Treap<T: Ord> {
  type Side (line 29) | enum Side {
  function new (line 35) | pub fn new() -> Treap<T> {
  function contains (line 43) | pub fn contains(&self, value: &T) -> bool {
  function insert (line 58) | pub fn insert(&mut self, value: T) -> bool {
  function remove (line 69) | pub fn remove(&mut self, value: &T) -> bool {
  function len (line 78) | pub fn len(&self) -> usize {
  function is_empty (line 83) | pub fn is_empty(&self) -> bool {
  function node_iter (line 88) | fn node_iter(&self) -> NodeIter<'_, T> {
  function iter (line 100) | pub fn iter(&self) -> Iter<'_, T> {
  function rand (line 108) | fn rand() -> usize {
  function insert (line 116) | fn insert<T: Ord>(tree: &mut Option<Box<TreapNode<T>>>, value: T) -> bool {
  function remove (line 139) | fn remove<T: Ord>(tree: &mut Option<Box<TreapNode<T>>>, value: &T) -> bo...
  function child (line 174) | fn child(&self, side: Side) -> &Option<Box<TreapNode<T>>> {
  function child_mut (line 182) | fn child_mut(&mut self, side: Side) -> &mut Option<Box<TreapNode<T>>> {
  function priority (line 190) | fn priority(&self, side: Side) -> usize {
  function rotate (line 195) | fn rotate(&mut self, side: Side) {
  function rebalance (line 209) | fn rebalance(&mut self) {
  function is_valid (line 222) | fn is_valid(&self) -> bool {
  method default (line 228) | fn default() -> Self {
  type Output (line 234) | type Output = Side;
  method not (line 236) | fn not(self) -> Self::Output {
  function from_iter (line 245) | fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
  type NodeIter (line 257) | struct NodeIter<'a, T: Ord> {
  type Item (line 262) | type Item = &'a TreapNode<T>;
  method next (line 264) | fn next(&mut self) -> Option<Self::Item> {
  type Iter (line 282) | pub struct Iter<'a, T: Ord> {
  type Item (line 287) | type Item = &'a T;
  method next (line 289) | fn next(&mut self) -> Option<&'a T> {
  function is_valid (line 302) | fn is_valid<T: Ord>(tree: &Treap<T>) -> bool {
  function len (line 307) | fn len() {
  function contains (line 313) | fn contains() {
  function insert (line 320) | fn insert() {
  function remove (line 329) | fn remove() {
  function sorted (line 338) | fn sorted() {
  function valid (line 344) | fn valid() {

FILE: src/data_structures/trie.rs
  type Node (line 11) | struct Node<Key: Default, Type: Default> {
  type Trie (line 21) | pub struct Trie<Key, Type>
  function new (line 39) | pub fn new() -> Self {
  function insert (line 50) | pub fn insert(&mut self, key: impl IntoIterator<Item = Key>, value: Type)
  function get (line 69) | pub fn get(&self, key: impl IntoIterator<Item = Key>) -> Option<&Type>
  function test_insertion_and_retrieval_with_strings (line 86) | fn test_insertion_and_retrieval_with_strings() {
  function test_insertion_and_retrieval_with_integers (line 101) | fn test_insertion_and_retrieval_with_integers() {
  function test_empty_trie (line 116) | fn test_empty_trie() {
  function test_insert_empty_key (line 124) | fn test_insert_empty_key() {
  function test_overlapping_keys (line 133) | fn test_overlapping_keys() {
  function test_partial_match (line 146) | fn test_partial_match() {

FILE: src/data_structures/union_find.rs
  type UnionFind (line 14) | pub struct UnionFind<T: Debug + Eq + Hash> {
  function with_capacity (line 23) | pub fn with_capacity(capacity: usize) -> Self {
  function insert (line 33) | pub fn insert(&mut self, item: T) {
  function find (line 42) | pub fn find(&mut self, value: &T) -> Option<usize> {
  function union (line 53) | pub fn union(&mut self, first_item: &T, sec_item: &T) -> Option<bool> {
  function find_by_key (line 62) | fn find_by_key(&mut self, key: usize) -> usize {
  function union_by_key (line 70) | fn union_by_key(&mut self, first_key: usize, sec_key: usize) -> bool {
  function is_same_set (line 93) | pub fn is_same_set(&mut self, first_item: &T, sec_item: &T) -> bool {
  function count (line 98) | pub fn count(&self) -> usize {
  method default (line 104) | fn default() -> Self {
  function from_iter (line 116) | fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
  function test_union_find (line 130) | fn test_union_find() {
  function test_spanning_tree (line 175) | fn test_spanning_tree() {
  function test_with_capacity (line 202) | fn test_with_capacity() {

FILE: src/data_structures/veb_tree.rs
  type VebTree (line 4) | pub struct VebTree {
    method new (line 16) | pub fn new(size: u32) -> VebTree {
    method high (line 41) | fn high(&self, value: u32) -> u32 {
    method low (line 45) | fn low(&self, value: u32) -> u32 {
    method index (line 49) | fn index(&self, cluster: u32, offset: u32) -> u32 {
    method min (line 53) | pub fn min(&self) -> u32 {
    method max (line 57) | pub fn max(&self) -> u32 {
    method iter (line 61) | pub fn iter(&self) -> VebTreeIter<'_> {
    method empty (line 66) | pub fn empty(&self) -> bool {
    method search (line 71) | pub fn search(&self, value: u32) -> bool {
    method insert_empty (line 82) | fn insert_empty(&mut self, value: u32) {
    method insert (line 89) | pub fn insert(&mut self, mut value: u32) {
    method succ (line 128) | pub fn succ(&self, pred: u32) -> Option<u32> {
    method pred (line 167) | pub fn pred(&self, succ: u32) -> Option<u32> {
  type VebTreeIter (line 212) | pub struct VebTreeIter<'a> {
  function new (line 218) | pub fn new(tree: &'a VebTree) -> VebTreeIter<'a> {
  type Item (line 225) | type Item = u32;
  method next (line 227) | fn next(&mut self) -> Option<u32> {
  function test_veb_tree (line 240) | fn test_veb_tree(size: u32, mut elements: Vec<u32>, exclude: Vec<u32>) {
  function test_empty (line 268) | fn test_empty() {
  function test_single (line 273) | fn test_single() {
  function test_two (line 278) | fn test_two() {
  function test_repeat_insert (line 287) | fn test_repeat_insert() {
  function test_linear (line 300) | fn test_linear() {
  function test_full (line 304) | fn test_full(size: u32) {
  function test_full_small (line 309) | fn test_full_small() {
  function test_full_256 (line 318) | fn test_full_256() {
  function test_10_256 (line 323) | fn test_10_256() {
  function test_100_256 (line 330) | fn test_100_256() {
  function test_100_300 (line 337) | fn test_100_300() {

FILE: src/dynamic_programming/catalan_numbers.rs
  function catalan_numbers (line 51) | pub fn catalan_numbers(upper_limit: usize) -> Vec<u64> {
  function test_catalan_numbers_basic (line 77) | fn test_catalan_numbers_basic() {
  function test_catalan_numbers_single (line 84) | fn test_catalan_numbers_single() {
  function test_catalan_numbers_extended (line 89) | fn test_catalan_numbers_extended() {
  function test_catalan_first_few (line 106) | fn test_catalan_first_few() {

FILE: src/dynamic_programming/coin_change.rs
  function coin_change (line 26) | pub fn coin_change(coins: &[usize], amount: usize) -> Option<usize> {

FILE: src/dynamic_programming/egg_dropping.rs
  function egg_drop (line 16) | pub fn egg_drop(eggs: usize, floors: usize) -> Option<usize> {

FILE: src/dynamic_programming/fibonacci.rs
  function fibonacci (line 9) | pub fn fibonacci(n: u32) -> u128 {
  function recursive_fibonacci (line 28) | pub fn recursive_fibonacci(n: u32) -> u128 {
  function _recursive_fibonacci (line 34) | fn _recursive_fibonacci(n: u32, previous: u128, current: u128) -> u128 {
  function classical_fibonacci (line 47) | pub fn classical_fibonacci(n: u32) -> u128 {
  function logarithmic_fibonacci (line 70) | pub fn logarithmic_fibonacci(n: u32) -> u128 {
  function _logarithmic_fibonacci (line 82) | fn _logarithmic_fibonacci(n: u32) -> (u128, u128) {
  function memoized_fibonacci (line 99) | pub fn memoized_fibonacci(n: u32) -> u128 {
  function _memoized_fibonacci (line 105) | fn _memoized_fibonacci(n: u32, cache: &mut HashMap<u32, u128>) -> u128 {
  function matrix_fibonacci (line 135) | pub fn matrix_fibonacci(n: u32) -> u128 {
  function matrix_power (line 146) | fn matrix_power(base: &Vec<Vec<u128>>, power: u32) -> Vec<Vec<u128>> {
  function matrix_multiply (line 156) | fn matrix_multiply(multiplier: &[Vec<u128>], multiplicand: &[Vec<u128>])...
  function binary_lifting_fibonacci (line 192) | pub fn binary_lifting_fibonacci(n: u32) -> u128 {
  function nth_fibonacci_number_modulo_m (line 212) | pub fn nth_fibonacci_number_modulo_m(n: i64, m: i64) -> i128 {
  function get_pisano_sequence_and_period (line 222) | fn get_pisano_sequence_and_period(m: i64) -> (i128, Vec<i128>) {
  function last_digit_of_the_sum_of_nth_fibonacci_number (line 257) | pub fn last_digit_of_the_sum_of_nth_fibonacci_number(n: i64) -> i64 {
  function test_fibonacci (line 292) | fn test_fibonacci() {
  function test_recursive_fibonacci (line 306) | fn test_recursive_fibonacci() {
  function test_classical_fibonacci (line 323) | fn test_classical_fibonacci() {
  function test_logarithmic_fibonacci (line 341) | fn test_logarithmic_fibonacci() {
  function test_iterative_and_recursive_equivalence (line 361) | fn test_iterative_and_recursive_equivalence() {
  function test_classical_and_combinatorial_are_off_by_one (line 379) | fn test_classical_and_combinatorial_are_off_by_one() {
  function test_memoized_fibonacci (line 394) | fn test_memoized_fibonacci() {
  function test_matrix_fibonacci (line 412) | fn test_matrix_fibonacci() {
  function test_binary_lifting_fibonacci (line 430) | fn test_binary_lifting_fibonacci() {
  function test_nth_fibonacci_number_modulo_m (line 448) | fn test_nth_fibonacci_number_modulo_m() {
  function test_last_digit_of_the_sum_of_nth_fibonacci_number (line 463) | fn test_last_digit_of_the_sum_of_nth_fibonacci_number() {

FILE: src/dynamic_programming/fractional_knapsack.rs
  function fractional_knapsack (line 1) | pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values:...
  function test (line 39) | fn test() {
  function test2 (line 47) | fn test2() {
  function test3 (line 55) | fn test3() {
  function test4 (line 63) | fn test4() {
  function test5 (line 71) | fn test5() {
  function test6 (line 82) | fn test6() {
  function test_nan (line 91) | fn test_nan() {

FILE: src/dynamic_programming/integer_partition.rs
  function partition (line 37) | pub fn partition(m: i32) -> u128 {
  function test_partition_5 (line 77) | fn test_partition_5() {
  function test_partition_7 (line 82) | fn test_partition_7() {
  function test_partition_100 (line 88) | fn test_partition_100() {
  function test_partition_1000 (line 94) | fn test_partition_1000() {
  function test_partition_negative (line 100) | fn test_partition_negative() {
  function test_partition_zero (line 106) | fn test_partition_zero() {
  function test_partition_small_values (line 111) | fn test_partition_small_values() {

FILE: src/dynamic_programming/is_subsequence.rs
  function is_subsequence (line 18) | pub fn is_subsequence(sub: &str, main: &str) -> bool {

FILE: src/dynamic_programming/knapsack.rs
  type Item (line 8) | pub struct Item {
  type KnapsackSolution (line 15) | pub struct KnapsackSolution {
  function knapsack (line 45) | pub fn knapsack(capacity: usize, items: Vec<Item>) -> KnapsackSolution {
  function generate_knapsack_matrix (line 72) | fn generate_knapsack_matrix(
  function retrieve_knapsack_items (line 111) | fn retrieve_knapsack_items(

FILE: src/dynamic_programming/longest_common_subsequence.rs
  function longest_common_subsequence (line 28) | pub fn longest_common_subsequence(first_seq: &str, second_seq: &str) -> ...
  function initialize_lcs_lengths (line 38) | fn initialize_lcs_lengths(first_seq_chars: &[char], second_seq_chars: &[...
  function reconstruct_lcs (line 58) | fn reconstruct_lcs(

FILE: src/dynamic_programming/longest_common_substring.rs
  function longest_common_substring (line 20) | pub fn longest_common_substring(s1: &str, s2: &str) -> usize {

FILE: src/dynamic_programming/longest_continuous_increasing_subsequence.rs
  function longest_continuous_increasing_subsequence (line 17) | pub fn longest_continuous_increasing_subsequence<T: Ord>(arr: &[T]) -> &...

FILE: src/dynamic_programming/longest_increasing_subsequence.rs
  function longest_increasing_subsequence (line 7) | pub fn longest_increasing_subsequence<T: Ord + Clone>(input_array: &[T])...
  function test_empty_vec (line 54) | fn test_empty_vec() {
  function test_example_1 (line 59) | fn test_example_1() {
  function test_example_2 (line 67) | fn test_example_2() {
  function test_example_3 (line 75) | fn test_example_3() {
  function test_tle (line 83) | fn test_tle() {
  function test_negative_elements (line 106) | fn test_negative_elements() {

FILE: src/dynamic_programming/matrix_chain_multiply.rs
  type MatrixChainMultiplicationError (line 14) | pub enum MatrixChainMultiplicationError {
  function matrix_chain_multiply (line 35) | pub fn matrix_chain_multiply(

FILE: src/dynamic_programming/maximal_square.rs
  function maximal_square (line 15) | pub fn maximal_square(matrix: &mut [Vec<i32>]) -> i32 {
  function test (line 49) | fn test() {

FILE: src/dynamic_programming/maximum_subarray.rs
  type MaximumSubarrayError (line 7) | pub enum MaximumSubarrayError {
  function maximum_subarray (line 30) | pub fn maximum_subarray(array: &[isize]) -> Result<isize, MaximumSubarra...

FILE: src/dynamic_programming/minimum_cost_path.rs
  type MatrixError (line 5) | pub enum MatrixError {
  function minimum_cost_path (line 32) | pub fn minimum_cost_path(matrix: Vec<Vec<usize>>) -> Result<usize, Matri...

FILE: src/dynamic_programming/optimal_bst.rs
  function optimal_search_tree (line 13) | pub fn optimal_search_tree(freq: &[i32]) -> i32 {

FILE: src/dynamic_programming/palindrome_partitioning.rs
  function minimum_palindrome_partitions (line 38) | pub fn minimum_palindrome_partitions(s: &str) -> usize {
  function test_basic_cases (line 85) | fn test_basic_cases() {
  function test_edge_cases (line 97) | fn test_edge_cases() {
  function test_palindromes (line 109) | fn test_palindromes() {
  function test_non_palindromes (line 117) | fn test_non_palindromes() {
  function test_longer_strings (line 126) | fn test_longer_strings() {

FILE: src/dynamic_programming/rod_cutting.rs
  function rod_cut (line 14) | pub fn rod_cut(prices: &[usize]) -> usize {

FILE: src/dynamic_programming/smith_waterman.rs
  function score_function (line 59) | pub fn score_function(
  function smith_waterman (line 101) | pub fn smith_waterman(
  function traceback (line 173) | pub fn traceback(
  function test_score_function_match (line 359) | fn test_score_function_match() {
  function test_score_function_mismatch (line 365) | fn test_score_function_mismatch() {
  function test_score_function_gap (line 371) | fn test_score_function_gap() {
  function test_case_insensitive (line 377) | fn test_case_insensitive() {
  function test_custom_scoring_end_to_end (line 387) | fn test_custom_scoring_end_to_end() {
  function test_alignment_at_boundary (line 416) | fn test_alignment_at_boundary() {

FILE: src/dynamic_programming/snail.rs
  function snail (line 5) | pub fn snail<T: Copy>(matrix: &[Vec<T>]) -> Vec<T> {
  type Direction (line 42) | enum Direction {
    method snail_move (line 50) | pub fn snail_move(
  function test_empty (line 112) | fn test_empty() {
  function test_int (line 118) | fn test_int() {
  function test_char (line 124) | fn test_char() {
  function test_rect (line 137) | fn test_rect() {

FILE: src/dynamic_programming/subset_generation.rs
  function list_subset (line 4) | pub fn list_subset(
  function test_print_subset3 (line 46) | fn test_print_subset3() {
  function test_print_subset4 (line 72) | fn test_print_subset4() {
  function test_print_subset5 (line 93) | fn test_print_subset5() {
  function test_print_incorrect_subset (line 105) | fn test_print_incorrect_subset() {

FILE: src/dynamic_programming/subset_sum.rs
  function is_sum_subset (line 15) | pub fn is_sum_subset(arr: &[i32], required_sum: i32) -> bool {

FILE: src/dynamic_programming/task_assignment.rs
  function count_task_assignments (line 18) | pub fn count_task_assignments(task_performed: Vec<Vec<usize>>, total_tas...

FILE: src/dynamic_programming/trapped_rainwater.rs
  function trapped_rainwater (line 12) | pub fn trapped_rainwater(elevation_map: &[u32]) -> u32 {
  function calculate_max_values (line 35) | fn calculate_max_values(elevation_map: &[u32], reverse: bool) -> Vec<u32> {
  function create_iter (line 57) | fn create_iter(len: usize, reverse: bool) -> Box<dyn Iterator<Item = usi...

FILE: src/dynamic_programming/word_break.rs
  function word_break (line 12) | pub fn word_break(s: &str, word_dict: &[&str]) -> bool {
  function search (line 34) | fn search(trie: &Trie<char, bool>, s: &str, start: usize, memo: &mut Vec...

FILE: src/financial/depreciation.rs
  type DepreciationError (line 29) | pub enum DepreciationError {
    method fmt (line 43) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  function validate_common (line 67) | fn validate_common(
  function straight_line_depreciation (line 111) | pub fn straight_line_depreciation(
  function diminishing_balance_depreciation (line 172) | pub fn diminishing_balance_depreciation(
  function units_of_production_depreciation (line 239) | pub fn units_of_production_depreciation(
  function sum_of_years_digits_depreciation (line 318) | pub fn sum_of_years_digits_depreciation(
  function double_declining_balance_depreciation (line 386) | pub fn double_declining_balance_depreciation(
  function sl_basic (line 438) | fn sl_basic() {
  function sl_six_years (line 445) | fn sl_six_years() {
  function sl_no_residual (line 451) | fn sl_no_residual() {
  function sl_sum_equals_depreciable_cost (line 457) | fn sl_sum_equals_depreciable_cost() {
  function sl_single_year (line 466) | fn sl_single_year() {
  function sl_err_zero_years (line 473) | fn sl_err_zero_years() {
  function sl_err_negative_purchase (line 481) | fn sl_err_negative_purchase() {
  function sl_err_residual_exceeds_purchase (line 489) | fn sl_err_residual_exceeds_purchase() {
  function db_sum_equals_depreciable_cost (line 499) | fn db_sum_equals_depreciable_cost() {
  function db_never_below_residual (line 509) | fn db_never_below_residual() {
  function db_err_rate_zero (line 522) | fn db_err_rate_zero() {
  function db_err_rate_above_one (line 530) | fn db_err_rate_above_one() {
  function up_sum_equals_depreciable_cost (line 540) | fn up_sum_equals_depreciable_cost() {
  function up_proportional_expenses (line 552) | fn up_proportional_expenses() {
  function up_err_units_mismatch (line 562) | fn up_err_units_mismatch() {
  function up_err_zero_total_units (line 570) | fn up_err_zero_total_units() {
  function syd_sum_equals_depreciable_cost (line 580) | fn syd_sum_equals_depreciable_cost() {
  function syd_first_year_fraction (line 589) | fn syd_first_year_fraction() {
  function syd_last_year_fraction (line 597) | fn syd_last_year_fraction() {
  function syd_decreasing_charges (line 605) | fn syd_decreasing_charges() {
  function syd_with_residual (line 614) | fn syd_with_residual() {
  function syd_single_year (line 623) | fn syd_single_year() {
  function syd_err_zero_years (line 630) | fn syd_err_zero_years() {
  function ddb_sum_equals_depreciable_cost (line 640) | fn ddb_sum_equals_depreciable_cost() {
  function ddb_first_year_is_double_sl (line 649) | fn ddb_first_year_is_double_sl() {
  function ddb_never_below_residual (line 657) | fn ddb_never_below_residual() {
  function ddb_switches_to_sl (line 669) | fn ddb_switches_to_sl() {
  function ddb_err_zero_years (line 678) | fn ddb_err_zero_years() {
  function ddb_err_residual_exceeds_purchase (line 686) | fn ddb_err_residual_exceeds_purchase() {

FILE: src/financial/equated_monthly_installments.rs
  function equated_monthly_installments (line 20) | pub fn equated_monthly_installments(
  function test_equated_monthly_installments (line 55) | fn test_equated_monthly_installments() {

FILE: src/financial/exponential_moving_average.rs
  function exponential_moving_average (line 35) | pub fn exponential_moving_average(
  function approx_eq (line 69) | fn approx_eq(a: f64, b: f64) -> bool {
  function test_basic_ema (line 74) | fn test_basic_ema() {
  function test_window_size_one (line 88) | fn test_window_size_one() {
  function test_single_price (line 101) | fn test_single_price() {
  function test_empty_prices (line 110) | fn test_empty_prices() {
  function test_zero_window_size_returns_error (line 119) | fn test_zero_window_size_returns_error() {

FILE: src/financial/finance_ratios.rs
  function return_on_investment (line 3) | pub fn return_on_investment(gain: f64, cost: f64) -> f64 {
  function debt_to_equity (line 7) | pub fn debt_to_equity(debt: f64, equity: f64) -> f64 {
  function gross_profit_margin (line 11) | pub fn gross_profit_margin(revenue: f64, cost: f64) -> f64 {
  function earnings_per_sale (line 15) | pub fn earnings_per_sale(net_income: f64, pref_dividend: f64, share_avg:...
  function test_return_on_investment (line 24) | fn test_return_on_investment() {
  function test_debt_to_equity (line 31) | fn test_debt_to_equity() {
  function test_gross_profit_margin (line 38) | fn test_gross_profit_margin() {
  function test_earnings_per_sale (line 45) | fn test_earnings_per_sale() {

FILE: src/financial/interest.rs
  function simple_interest (line 25) | pub fn simple_interest(
  function compound_interest (line 51) | pub fn compound_interest(
  function apr_interest (line 83) | pub fn apr_interest(
  function test_simple_interest (line 111) | fn test_simple_interest() {
  function test_compound_interest (line 147) | fn test_compound_interest() {
  function test_apr_interest (line 182) | fn test_apr_interest() {

FILE: src/financial/npv.rs
  function npv (line 5) | pub fn npv(cash_flows: &[f64], rate: f64) -> f64 {
  function test_npv_basic (line 20) | fn test_npv_basic() {
  function test_npv_zero_rate (line 29) | fn test_npv_zero_rate() {
  function test_npv_empty (line 37) | fn test_npv_empty() {

FILE: src/financial/npv_sensitivity.rs
  function npv_sensitivity (line 14) | pub fn npv_sensitivity(cash_flows: &[f64], discount_rates: &[f64]) -> Ve...
  function test_npv_sensitivity (line 32) | fn test_npv_sensitivity() {

FILE: src/financial/payback.rs
  function payback (line 4) | pub fn payback(cash_flow: &[f64]) -> Option<usize> {
  function test_payback (line 20) | fn test_payback() {
  function test_no_payback (line 26) | fn test_no_payback() {

FILE: src/financial/present_value.rs
  type PresentValueError (line 7) | pub enum PresentValueError {
  function present_value (line 12) | pub fn present_value(discount_rate: f64, cash_flows: Vec<f64>) -> Result...
  function round (line 29) | fn round(value: f64) -> f64 {

FILE: src/financial/treynor_ratio.rs
  function treynor_ratio (line 11) | pub fn treynor_ratio(portfolio_return: f64, risk_free_rate: f64, beta: f...
  function test_treynor_ratio (line 24) | fn test_treynor_ratio() {
  function test_treynor_ratio_empty_beta (line 31) | fn test_treynor_ratio_empty_beta() {

FILE: src/general/convex_hull.rs
  function sort_by_min_angle (line 3) | fn sort_by_min_angle(pts: &[(f64, f64)], min: &(f64, f64)) -> Vec<(f64, ...
  function calc_z_coord_vector_product (line 21) | fn calc_z_coord_vector_product(a: &(f64, f64), b: &(f64, f64), c: &(f64,...
  function convex_hull_graham (line 32) | pub fn convex_hull_graham(pts: &[(f64, f64)]) -> Vec<(f64, f64)> {
  function empty (line 72) | fn empty() {
  function not_enough_points (line 77) | fn not_enough_points() {
  function not_enough_points1 (line 83) | fn not_enough_points1() {
  function not_enough_points2 (line 90) | fn not_enough_points2() {
  function lots_of_points (line 98) | fn lots_of_points() {
  function lots_of_points2 (line 135) | fn lots_of_points2() {

FILE: src/general/fisher_yates_shuffle.rs
  constant DEFAULT (line 5) | const DEFAULT: u64 = 4294967296;
  function gen_range (line 7) | fn gen_range(range: usize, generator: &mut PCG32) -> usize {
  function fisher_yates_shuffle (line 11) | pub fn fisher_yates_shuffle(array: &mut [i32]) {

FILE: src/general/genetic.rs
  type Chromosome (line 13) | pub trait Chromosome<Rng: rand::RngExt, Eval> {
    method mutate (line 15) | fn mutate(&mut self, rng: &mut Rng);
    method crossover (line 18) | fn crossover(&self, other: &Self, rng: &mut Rng) -> Self;
    method fitness (line 22) | fn fitness(&self) -> Eval;
  type SelectionStrategy (line 25) | pub trait SelectionStrategy<Rng: rand::RngExt> {
    method new (line 26) | fn new(rng: Rng) -> Self;
    method select (line 31) | fn select<'a, Eval: Into<f64>, C: Chromosome<Rng, Eval>>(
  type RouletteWheel (line 40) | pub struct RouletteWheel<Rng: rand::RngExt> {
  function new (line 44) | fn new(rng: Rng) -> Self {
  function select (line 48) | fn select<'a, Eval: Into<f64>, C: Chromosome<Rng, Eval>>(
  type Tournament (line 89) | pub struct Tournament<const K: usize, Rng: rand::RngExt> {
  function new (line 93) | fn new(rng: Rng) -> Self {
  function select (line 97) | fn select<'a, Eval, C: Chromosome<Rng, Eval>>(
  type Comparator (line 119) | type Comparator<T> = Box<dyn FnMut(&T, &T) -> Ordering>;
  type GeneticAlgorithm (line 120) | pub struct GeneticAlgorithm<
  type GenericAlgorithmParams (line 136) | pub struct GenericAlgorithmParams {
  function init (line 149) | pub fn init(
  function solve (line 174) | pub fn solve(&mut self) -> Option<C> {
  function find_secret (line 232) | fn find_secret() {
  function solve_mastermind (line 318) | fn solve_mastermind() {

FILE: src/general/hanoi.rs
  function hanoi (line 1) | pub fn hanoi(n: i32, from: i32, to: i32, via: i32, moves: &mut Vec<(i32,...
  function hanoi_simple (line 14) | fn hanoi_simple() {

FILE: src/general/huffman_encoding.rs
  type HuffmanValue (line 7) | pub struct HuffmanValue {
  type HuffmanNode (line 16) | pub struct HuffmanNode<T> {
  method eq (line 24) | fn eq(&self, other: &Self) -> bool {
  method partial_cmp (line 30) | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
  method cmp (line 38) | fn cmp(&self, other: &Self) -> Ordering {
  function get_alphabet (line 45) | pub fn get_alphabet(
  type HuffmanDictionary (line 74) | pub struct HuffmanDictionary<T> {
  function new (line 93) | pub fn new(alphabet: &[(T, u64)]) -> Option<Self> {
  function encode (line 154) | pub fn encode(&self, data: &[T]) -> HuffmanEncoding {
  type HuffmanEncoding (line 162) | pub struct HuffmanEncoding {
    method new (line 174) | pub fn new() -> Self {
    method add_data (line 181) | pub fn add_data(&mut self, data: HuffmanValue) {
    method get_bit (line 192) | fn get_bit(&self, pos: u64) -> bool {
    method decode (line 197) | pub fn decode<T: Clone + Copy + Ord>(&self, dict: &HuffmanDictionary<T...
  method default (line 168) | fn default() -> Self {
  function get_frequency (line 239) | fn get_frequency(bytes: &[u8]) -> Vec<(u8, u64)> {
  function empty_text (line 253) | fn empty_text() {
  function one_symbol_text (line 262) | fn one_symbol_text() {
  function test_decode_empty_encoding_struct (line 274) | fn test_decode_empty_encoding_struct() {
  function minimal_decode_end_check (line 293) | fn minimal_decode_end_check() {
  function test_decode_corrupted_stream_dead_end (line 307) | fn test_decode_corrupted_stream_dead_end() {
  function small_text (line 337) | fn small_text() {
  function lorem_ipsum (line 348) | fn lorem_ipsum() {

FILE: src/general/kadane_algorithm.rs
  function max_sub_array (line 21) | pub fn max_sub_array(nums: Vec<i32>) -> i32 {
  function test_kadanes_algorithm_positive (line 46) | fn test_kadanes_algorithm_positive() {
  function test_kadanes_algorithm_negative (line 55) | fn test_kadanes_algorithm_negative() {
  function test_kadanes_algorithm_mixed (line 64) | fn test_kadanes_algorithm_mixed() {
  function test_kadanes_algorithm_empty (line 73) | fn test_kadanes_algorithm_empty() {
  function test_kadanes_algorithm_single_positive (line 82) | fn test_kadanes_algorithm_single_positive() {

FILE: src/general/kmeans.rs
  function easy_univariate_clustering (line 108) | fn easy_univariate_clustering() {
  function easy_univariate_clustering_odd_number_of_data (line 124) | fn easy_univariate_clustering_odd_number_of_data() {
  function easy_bivariate_clustering (line 141) | fn easy_bivariate_clustering() {
  function high_dims (line 157) | fn high_dims() {

FILE: src/general/mex.rs
  function mex_using_set (line 7) | pub fn mex_using_set(arr: &[i64]) -> i64 {
  function mex_using_sort (line 26) | pub fn mex_using_sort(arr: &[i64]) -> i64 {
  type MexTests (line 41) | struct MexTests {
    method new (line 46) | fn new() -> Self {
    method test_function (line 62) | fn test_function(&self, f: fn(&[i64]) -> i64) {
  function test_mex_using_set (line 69) | fn test_mex_using_set() {
  function test_mex_using_sort (line 75) | fn test_mex_using_sort() {

FILE: src/general/permutations/heap.rs
  function heap_permute (line 5) | pub fn heap_permute<T: Clone + Debug>(arr: &[T]) -> Vec<Vec<T>> {
  function heap_recurse (line 16) | fn heap_recurse<T: Clone + Debug>(arr: &mut [T], k: usize, collector: &m...
  function test_3_different_values (line 42) | fn test_3_different_values() {
  function test_3_times_the_same_value (line 52) | fn test_3_times_the_same_value() {
  function test_some_elements (line 62) | fn test_some_elements(NotTooBigVec { inner: original }: NotTooBigVec) {

FILE: src/general/permutations/mod.rs
  function assert_permutations (line 14) | pub fn assert_permutations(original: &[i32], permutations: &[Vec<i32>]) {
  function assert_valid_permutation (line 26) | pub fn assert_valid_permutation(original: &[i32], permuted: &[i32]) {
  function test_valid_permutations (line 45) | fn test_valid_permutations() {
  function test_invalid_permutation_1 (line 56) | fn test_invalid_permutation_1() {
  function test_invalid_permutation_2 (line 62) | fn test_invalid_permutation_2() {
  function test_invalid_permutation_3 (line 68) | fn test_invalid_permutation_3() {
  function test_invalid_permutation_repeat (line 74) | fn test_invalid_permutation_repeat() {
  type NotTooBigVec (line 81) | pub struct NotTooBigVec {
  constant MAX_SIZE (line 85) | const MAX_SIZE: usize = 8;
  method arbitrary (line 87) | fn arbitrary(g: &mut Gen) -> Self {

FILE: src/general/permutations/naive.rs
  function permute (line 6) | pub fn permute<T: Clone + Debug>(arr: &[T]) -> Vec<Vec<T>> {
  function permute_recurse (line 22) | fn permute_recurse<T: Clone + Debug>(arr: &mut Vec<T>, k: usize, collect...
  function permute_unique (line 37) | pub fn permute_unique<T: Clone + Debug + Eq + Hash + Copy>(arr: &[T]) ->...
  function permute_recurse_unique (line 49) | fn permute_recurse_unique<T: Clone + Debug + Eq + Hash + Copy>(
  function test_3_different_values (line 90) | fn test_3_different_values() {
  function empty_array (line 100) | fn empty_array() {
  function test_3_times_the_same_value (line 107) | fn test_3_times_the_same_value() {
  function test_some_elements (line 117) | fn test_some_elements(NotTooBigVec { inner: original }: NotTooBigVec) {
  function test_unique_values (line 123) | fn test_unique_values() {

FILE: src/general/permutations/steinhaus_johnson_trotter.rs
  function steinhaus_johnson_trotter_permute (line 2) | pub fn steinhaus_johnson_trotter_permute<T: Clone>(array: &[T]) -> Vec<V...
  function test_3_different_values (line 37) | fn test_3_different_values() {
  function test_3_times_the_same_value (line 47) | fn test_3_times_the_same_value() {
  function test_some_elements (line 57) | fn test_some_elements(NotTooBigVec { inner: original }: NotTooBigVec) {

FILE: src/general/subarray_sum_equals_k.rs
  function subarray_sum_equals_k (line 19) | pub fn subarray_sum_equals_k(nums: &[i32], k: i32) -> i32 {
  function test_basic (line 45) | fn test_basic() {
  function test_single_element (line 51) | fn test_single_element() {
  function test_empty (line 57) | fn test_empty() {
  function test_negative_numbers (line 63) | fn test_negative_numbers() {
  function test_no_match (line 69) | fn test_no_match() {
  function test_multiple_matches (line 74) | fn test_multiple_matches() {

FILE: src/general/two_sum.rs
  function two_sum (line 18) | pub fn two_sum(nums: Vec<i32>, target: i32) -> Option<(usize, usize)> {
  function test (line 52) | fn test() {

FILE: src/geometry/closest_points.rs
  function cmp_x (line 4) | fn cmp_x(p1: &Point, p2: &Point) -> Ordering {
  function f64_cmp (line 12) | fn f64_cmp(a: &f64, b: &f64) -> Ordering {
  function closest_points (line 18) | pub fn closest_points(points: &[Point]) -> Option<(Point, Point)> {
  function closest_points_aux (line 29) | fn closest_points_aux(
  function eq (line 120) | fn eq(p1: Option<(Point, Point)>, p2: Option<(Point, Point)>) -> bool {
  function zero_points (line 140) | fn zero_points() {
  function one_points (line 146) | fn one_points() {
  function two_points (line 152) | fn two_points() {
  function three_points (line 161) | fn three_points() {
  function list_1 (line 170) | fn list_1() {
  function list_2 (line 191) | fn list_2() {
  function vertical_points (line 222) | fn vertical_points() {

FILE: src/geometry/graham_scan.rs
  function point_min (line 4) | fn point_min(a: &&Point, b: &&Point) -> Ordering {
  function graham_scan (line 15) | pub fn graham_scan(mut points: Vec<Point>) -> Vec<Point> {
  function test_graham (line 89) | fn test_graham(convex_hull: Vec<Point>, others: Vec<Point>) {
  function too_few_points (line 102) | fn too_few_points() {
  function duplicate_point (line 108) | fn duplicate_point() {
  function points_same_line (line 114) | fn points_same_line() {
  function triangle (line 125) | fn triangle() {
  function rectangle (line 134) | fn rectangle() {
  function triangle_with_points_in_middle (line 144) | fn triangle_with_points_in_middle() {
  function rectangle_with_points_in_middle (line 158) | fn rectangle_with_points_in_middle() {
  function star (line 174) | fn star() {
  function rectangle_with_points_on_same_line (line 193) | fn rectangle_with_points_on_same_line() {

FILE: src/geometry/jarvis_scan.rs
  function jarvis_march (line 6) | pub fn jarvis_march(points: Vec<Point>) -> Vec<Point> {
  function test_jarvis (line 76) | fn test_jarvis(convex_hull: Vec<Point>, others: Vec<Point>) {
  function too_few_points (line 89) | fn too_few_points() {
  function duplicate_point (line 95) | fn duplicate_point() {
  function points_same_line (line 101) | fn points_same_line() {
  function triangle (line 112) | fn triangle() {
  function rectangle (line 121) | fn rectangle() {
  function triangle_with_points_in_middle (line 131) | fn triangle_with_points_in_middle() {
  function rectangle_with_points_in_middle (line 145) | fn rectangle_with_points_in_middle() {
  function star (line 161) | fn star() {
  function rectangle_with_points_on_same_line (line 180) | fn rectangle_with_points_on_same_line() {

FILE: src/geometry/point.rs
  type Point (line 4) | pub struct Point {
    method new (line 10) | pub fn new(x: f64, y: f64) -> Point {
    method consecutive_orientation (line 15) | pub fn consecutive_orientation(&self, b: &Point, c: &Point) -> f64 {
    method cross_prod (line 21) | pub fn cross_prod(&self, other: &Point) -> f64 {
    method euclidean_distance (line 25) | pub fn euclidean_distance(&self, other: &Point) -> f64 {
  type Output (line 31) | type Output = Point;
  method sub (line 33) | fn sub(self, other: Self) -> Point {

FILE: src/geometry/polygon_points.rs
  type Ll (line 1) | type Ll = i64;
  type Pll (line 2) | type Pll = (Ll, Ll);
  function cross (line 4) | fn cross(x1: Ll, y1: Ll, x2: Ll, y2: Ll) -> Ll {
  function polygon_area (line 8) | pub fn polygon_area(pts: &[Pll]) -> Ll {
  function gcd (line 21) | fn gcd(mut a: Ll, mut b: Ll) -> Ll {
  function boundary (line 30) | fn boundary(pts: &[Pll]) -> Ll {
  function lattice_points (line 40) | pub fn lattice_points(pts: &[Pll]) -> Ll {
  function test_calculate_cross (line 51) | fn test_calculate_cross() {
  function test_polygon_3_coordinates (line 56) | fn test_polygon_3_coordinates() {
  function test_polygon_4_coordinates (line 62) | fn test_polygon_4_coordinates() {
  function test_gcd_multiple_of_common_factor (line 68) | fn test_gcd_multiple_of_common_factor() {
  function test_boundary (line 73) | fn test_boundary() {
  function test_lattice_points (line 79) | fn test_lattice_points() {

FILE: src/geometry/ramer_douglas_peucker.rs
  function ramer_douglas_peucker (line 3) | pub fn ramer_douglas_peucker(points: &[Point], epsilon: f64) -> Vec<Poin...
  function perpendicular_distance (line 29) | fn perpendicular_distance(p: &Point, a: &Point, b: &Point) -> f64 {
  function test_ramer_douglas_peucker_polygon (line 59) | fn test_ramer_douglas_peucker_polygon() {
  function test_ramer_douglas_peucker_polygonal_chain (line 84) | fn test_ramer_douglas_peucker_polygonal_chain() {
  function test_less_than_three_points (line 99) | fn test_less_than_three_points() {

FILE: src/geometry/segment.rs
  constant TOLERANCE (line 3) | const TOLERANCE: f64 = 0.0001;
  type Segment (line 5) | pub struct Segment {
    method new (line 11) | pub fn new(x1: f64, y1: f64, x2: f64, y2: f64) -> Segment {
    method from_points (line 18) | pub fn from_points(a: Point, b: Point) -> Segment {
    method direction (line 22) | pub fn direction(&self, p: &Point) -> f64 {
    method is_vertical (line 28) | pub fn is_vertical(&self) -> bool {
    method get_line_equation (line 33) | pub fn get_line_equation(&self) -> (f64, f64) {
    method compute_y_at_x (line 41) | pub fn compute_y_at_x(&self, x: f64) -> f64 {
    method is_colinear (line 46) | pub fn is_colinear(&self, p: &Point) -> bool {
    method colinear_point_on_segment (line 55) | pub fn colinear_point_on_segment(&self, p: &Point) -> bool {
    method on_segment (line 71) | pub fn on_segment(&self, p: &Point) -> bool {
    method intersects (line 78) | pub fn intersects(&self, other: &Segment) -> bool {
  function colinear (line 105) | fn colinear() {
  function colinear_vertical (line 127) | fn colinear_vertical() {
  function test_intersect (line 139) | fn test_intersect(s1: &Segment, s2: &Segment, result: bool) {
  function intersects (line 145) | fn intersects() {
  function intersects_endpoint_on_segment (line 159) | fn intersects_endpoint_on_segment() {
  function intersects_self (line 168) | fn intersects_self() {
  function too_short_to_intersect (line 175) | fn too_short_to_intersect() {
  function parallel_segments (line 185) | fn parallel_segments() {

FILE: src/graph/ant_colony_optimization.rs
  type City (line 22) | struct City {
    method distance_to (line 29) | fn distance_to(&self, other: &City) -> f64 {
  type AntColonyOptimization (line 37) | struct AntColonyOptimization {
    method new (line 50) | fn new(
    method solve (line 74) | fn solve(&mut self) -> Option<(Vec<usize>, f64)> {
    method construct_solutions (line 104) | fn construct_solutions(&self) -> Vec<Vec<usize>> {
    method construct_ant_solution (line 111) | fn construct_ant_solution(&self) -> Vec<usize> {
    method select_next_city (line 134) | fn select_next_city(&self, current: usize, unvisited: &HashSet<usize>)...
    method calculate_route_distance (line 166) | fn calculate_route_distance(&self, route: &[usize]) -> f64 {
    method update_pheromones (line 174) | fn update_pheromones(&mut self, routes: &[Vec<usize>]) {
  function ant_colony_optimization (line 236) | pub fn ant_colony_optimization(
  function test_city_distance (line 269) | fn test_city_distance() {
  function test_city_distance_negative (line 276) | fn test_city_distance_negative() {
  function test_aco_simple (line 283) | fn test_aco_simple() {
  function test_aco_larger_problem (line 300) | fn test_aco_larger_problem() {
  function test_aco_empty_cities (line 335) | fn test_aco_empty_cities() {
  function test_aco_single_city (line 342) | fn test_aco_single_city() {
  function test_default_parameters (line 353) | fn test_default_parameters() {
  function test_zero_ants (line 360) | fn test_zero_ants() {
  function test_zero_iterations (line 368) | fn test_zero_iterations() {
  function test_extreme_parameters (line 376) | fn test_extreme_parameters() {

FILE: src/graph/astar.rs
  type Graph (line 8) | type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>;
  type Candidate (line 11) | struct Candidate<V, E> {
  method partial_cmp (line 18) | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
  method cmp (line 26) | fn cmp(&self, other: &Self) -> std::cmp::Ordering {
  function astar (line 33) | pub fn astar<V: Ord + Copy, E: Ord + Copy + Add<Output = E> + Zero>(
  function null_heuristic (line 108) | fn null_heuristic<V, E: Zero>(_v: V) -> E {
  function add_edge (line 112) | fn add_edge<V: Ord + Copy, E: Ord>(graph: &mut Graph<V, E>, v1: V, v2: V...
  function single_vertex (line 118) | fn single_vertex() {
  function single_edge (line 127) | fn single_edge() {
  function graph_1 (line 136) | fn graph_1() {
  function test_heuristic (line 236) | fn test_heuristic() {

FILE: src/graph/bellman_ford.rs
  type Graph (line 6) | type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>;
  function bellman_ford (line 14) | pub fn bellman_ford<
  function add_edge (line 92) | fn add_edge<V: Ord + Copy, E: Ord>(graph: &mut Graph<V, E>, v1: V, v2: V...
  function single_vertex (line 98) | fn single_vertex() {
  function single_edge (line 109) | fn single_edge() {
  function tree_1 (line 126) | fn tree_1() {
  function graph_1 (line 150) | fn graph_1() {
  function graph_2 (line 194) | fn graph_2() {
  function graph_with_negative_loop (line 249) | fn graph_with_negative_loop() {

FILE: src/graph/bipartite_matching.rs
  type Graph (line 3) | type Graph = Vec<Vec<usize>>;
  type BipartiteMatching (line 5) | pub struct BipartiteMatching {
    method new (line 15) | pub fn new(num_vertices_grp1: usize, num_vertices_grp2: usize) -> Self {
    method add_edge (line 27) | pub fn add_edge(&mut self, u: usize, v: usize) {
    method try_kuhn (line 31) | fn try_kuhn(&mut self, cur: usize) -> bool {
    method kuhn (line 46) | pub fn kuhn(&mut self) {
    method print_matching (line 53) | pub fn print_matching(&self) {
    method bfs (line 61) | fn bfs(&self, dist: &mut [i32]) -> bool {
    method dfs (line 96) | fn dfs(&mut self, u: i32, dist: &mut Vec<i32>) -> bool {
    method hopcroft_karp (line 111) | pub fn hopcroft_karp(&mut self) -> i32 {
  function small_graph_kuhn (line 142) | fn small_graph_kuhn() {
  function small_graph_hopcroft (line 172) | fn small_graph_hopcroft() {
  function super_small_graph_kuhn (line 203) | fn super_small_graph_kuhn() {
  function super_small_graph_hopcroft (line 213) | fn super_small_graph_hopcroft() {
  function only_one_vertex_graph_kuhn (line 226) | fn only_one_vertex_graph_kuhn() {
  function only_one_vertex_graph_hopcroft (line 248) | fn only_one_vertex_graph_hopcroft() {

FILE: src/graph/breadth_first_search.rs
  function breadth_first_search (line 20) | pub fn breadth_first_search(graph: &Graph, root: Node, target: Node) -> ...
  type Node (line 50) | pub struct Node(u32);
    method from (line 69) | fn from(item: u32) -> Self {
    method value (line 75) | pub fn value(&self) -> u32 {
    method neighbors (line 79) | pub fn neighbors(&self, graph: &Graph) -> Vec<Node> {
  type Edge (line 53) | pub struct Edge(u32, u32);
    method from (line 90) | fn from(item: (u32, u32)) -> Self {
  type Graph (line 56) | pub struct Graph {
    method new (line 63) | pub fn new(nodes: Vec<Node>, edges: Vec<Edge>) -> Self {
  function graph1 (line 109) | fn graph1() -> Graph {
  function breadth_first_search_graph1_when_node_not_found_returns_none (line 120) | fn breadth_first_search_graph1_when_node_not_found_returns_none() {
  function breadth_first_search_graph1_when_target_8_should_evaluate_all_nodes_first (line 132) | fn breadth_first_search_graph1_when_target_8_should_evaluate_all_nodes_f...
  function graph2 (line 153) | fn graph2() -> Graph {
  function breadth_first_search_graph2_when_no_path_to_node_returns_none (line 179) | fn breadth_first_search_graph2_when_no_path_to_node_returns_none() {
  function breadth_first_search_graph2_should_find_path_from_4_to_1 (line 191) | fn breadth_first_search_graph2_should_find_path_from_4_to_1() {

FILE: src/graph/centroid_decomposition.rs
  type Adj (line 1) | type Adj = [Vec<usize>];
  constant IN_DECOMPOSITION (line 3) | const IN_DECOMPOSITION: u64 = 1 << 63;
  type CentroidDecomposition (line 15) | pub struct CentroidDecomposition {
    method new (line 29) | pub fn new(mut num_vertices: usize) -> Self {
    method put_in_decomposition (line 39) | fn put_in_decomposition(&mut self, v: usize, parent: usize) {
    method is_in_decomposition (line 44) | fn is_in_decomposition(&self, v: usize) -> bool {
    method dfs_size (line 47) | fn dfs_size(&mut self, v: usize, parent: usize, adj: &Adj) -> usize {
    method dfs_centroid (line 65) | fn dfs_centroid(&self, v: usize, size_thr: usize) -> usize {
    method decompose_subtree (line 72) | fn decompose_subtree(
    method decompose_tree (line 100) | pub fn decompose_tree(&mut self, adj: &Adj) {
  function calculate_height (line 112) | fn calculate_height(v: usize, heights: &mut [usize], parents: &mut [usiz...
  function single_path (line 119) | fn single_path() {
  function random_tree_height (line 139) | fn random_tree_height() {

FILE: src/graph/decremental_connectivity.rs
  type DecrementalConnectivity (line 12) | pub struct DecrementalConnectivity {
    method new (line 21) | pub fn new(adjacent: Vec<HashSet<usize>>) -> Result<Self, String> {
    method connected (line 37) | pub fn connected(&self, u: usize, v: usize) -> Option<bool> {
    method delete (line 44) | pub fn delete(&mut self, u: usize, v: usize) {
    method calc_component (line 70) | fn calc_component(&mut self) -> Vec<usize> {
    method is_smaller (line 93) | fn is_smaller(&mut self, u: usize, v: usize) -> bool {
    method dfs_step (line 112) | fn dfs_step(&mut self, queue: &mut Vec<usize>, dfs_id: usize) {
  function is_forest (line 126) | fn is_forest(adjacent: &Vec<HashSet<usize>>) -> bool {
  function has_cycle (line 139) | fn has_cycle(
  function construction_test (line 174) | fn construction_test() {
  function non_bidirectional_test (line 196) | fn non_bidirectional_test() {
  function delete_panic_test (line 215) | fn delete_panic_test() {
  function query_test (line 232) | fn query_test() {

FILE: src/graph/depth_first_search.rs
  function depth_first_search (line 8) | pub fn depth_first_search(graph: &Graph, root: Vertex, objective: Vertex...
  type Vertex (line 44) | pub struct Vertex(u32);
    method from (line 61) | fn from(item: u32) -> Self {
    method value (line 67) | pub fn value(&self) -> u32 {
    method neighbors (line 71) | pub fn neighbors(&self, graph: &Graph) -> VecDeque<Vertex> {
  type Edge (line 46) | pub struct Edge(u32, u32);
    method from (line 82) | fn from(item: (u32, u32)) -> Self {
  type Graph (line 48) | pub struct Graph {
    method new (line 55) | pub fn new(vertices: Vec<Vertex>, edges: Vec<Edge>) -> Self {
  function find_1_fail (line 92) | fn find_1_fail() {
  function find_1_sucess (line 111) | fn find_1_sucess() {
  function find_2_sucess (line 132) | fn find_2_sucess() {
  function find_3_sucess (line 163) | fn find_3_sucess() {

FILE: src/graph/depth_first_search_tic_tac_toe.rs
  type Position (line 34) | struct Position {
  type Players (line 40) | pub enum Players {
  type SinglePlayAction (line 47) | struct SinglePlayAction {
  type PlayActions (line 53) | pub struct PlayActions {
  function main (line 60) | fn main() {
  function display_board (line 136) | fn display_board(board: &[Vec<Players>]) {
  function available_positions (line 152) | fn available_positions(board: &[Vec<Players>]) -> Vec<Position> {
  function win_check (line 167) | fn win_check(player: Players, board: &[Vec<Players>]) -> bool {
  function minimax (line 195) | pub fn minimax(side: Players, board: &[Vec<Players>]) -> Option<PlayActi...
  function append_playaction (line 263) | fn append_playaction(
  function win_state_check (line 327) | fn win_state_check() {
  function win_state_check2 (line 337) | fn win_state_check2() {
  function block_win_move (line 349) | fn block_win_move() {
  function block_move (line 366) | fn block_move() {
  function expected_loss (line 382) | fn expected_loss() {

FILE: src/graph/detect_cycle.rs
  type DetectCycle (line 5) | pub trait DetectCycle {
    method detect_cycle_dfs (line 6) | fn detect_cycle_dfs(&self) -> bool;
    method detect_cycle_bfs (line 7) | fn detect_cycle_bfs(&self) -> bool;
    method detect_cycle_dfs (line 59) | fn detect_cycle_dfs(&self) -> bool {
    method detect_cycle_bfs (line 72) | fn detect_cycle_bfs(&self) -> bool {
    method detect_cycle_dfs (line 110) | fn detect_cycle_dfs(&self) -> bool {
    method detect_cycle_bfs (line 131) | fn detect_cycle_bfs(&self) -> bool {
  function undirected_graph_detect_cycle_dfs (line 11) | fn undirected_graph_detect_cycle_dfs<'a>(
  function undirected_graph_detect_cycle_bfs (line 32) | fn undirected_graph_detect_cycle_bfs<'a>(
  function directed_graph_detect_cycle_dfs (line 87) | fn directed_graph_detect_cycle_dfs<'a>(
  function get_undirected_single_node_with_loop (line 172) | fn get_undirected_single_node_with_loop() -> UndirectedGraph {
  function get_directed_single_node_with_loop (line 177) | fn get_directed_single_node_with_loop() -> DirectedGraph {
  function get_undirected_two_nodes_connected (line 182) | fn get_undirected_two_nodes_connected() -> UndirectedGraph {
  function get_directed_two_nodes_connected (line 187) | fn get_directed_two_nodes_connected() -> DirectedGraph {
  function get_directed_two_nodes (line 193) | fn get_directed_two_nodes() -> DirectedGraph {
  function get_undirected_triangle (line 198) | fn get_undirected_triangle() -> UndirectedGraph {
  function get_directed_triangle (line 205) | fn get_directed_triangle() -> DirectedGraph {
  function get_undirected_triangle_with_tail (line 212) | fn get_undirected_triangle_with_tail() -> UndirectedGraph {
  function get_directed_triangle_with_tail (line 220) | fn get_directed_triangle_with_tail() -> DirectedGraph {
  function get_undirected_graph_with_cycle (line 228) | fn get_undirected_graph_with_cycle() -> UndirectedGraph {
  function get_undirected_graph_without_cycle (line 237) | fn get_undirected_graph_without_cycle() -> UndirectedGraph {
  function get_directed_graph_with_cycle (line 245) | fn get_directed_graph_with_cycle() -> DirectedGraph {
  function get_directed_graph_without_cycle (line 254) | fn get_directed_graph_without_cycle() -> DirectedGraph {

FILE: src/graph/dijkstra.rs
  type Graph (line 4) | type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>;
  function dijkstra (line 15) | pub fn dijkstra<V: Ord + Copy, E: Ord + Copy + Add<Output = E>>(
  function add_edge (line 59) | fn add_edge<V: Ord + Copy, E: Ord>(graph: &mut Graph<V, E>, v1: V, v2: V...
  function single_vertex (line 65) | fn single_vertex() {
  function single_edge (line 76) | fn single_edge() {
  function tree_1 (line 93) | fn tree_1() {
  function graph_1 (line 117) | fn graph_1() {

FILE: src/graph/dinic_maxflow.rs
  type Graph (line 7) | type Graph = Vec<Vec<usize>>;
  type FlowEdge (line 10) | pub struct FlowEdge<T> {
  type FlowResultEdge (line 16) | pub struct FlowResultEdge<T> {
  function new (line 25) | pub fn new(sink: usize, capacity: T) -> Self {
  type DinicMaxFlow (line 34) | pub struct DinicMaxFlow<T> {
  function new (line 60) | pub fn new(source: usize, sink: usize, num_vertices: usize) -> Self {
  function add_edge (line 74) | pub fn add_edge(&mut self, source: usize, sink: usize, capacity: T) {
  function bfs (line 84) | fn bfs(&mut self) -> bool {
  function dfs (line 106) | fn dfs(&mut self, v: usize, pushed: T) -> T {
  function find_maxflow (line 134) | pub fn find_maxflow(&mut self, infinite_flow: T) -> T {
  function get_flow_edges (line 155) | pub fn get_flow_edges(&mut self, infinite_flow: T) -> Vec<FlowResultEdge...
  function small_graph (line 182) | fn small_graph() {

FILE: src/graph/disjoint_set_union.rs
  type DSUNode (line 7) | pub struct DSUNode {
  type DisjointSetUnion (line 17) | pub struct DisjointSetUnion {
    method new (line 32) | pub fn new(num_elements: usize) -> DisjointSetUnion {
    method find_set (line 56) | pub fn find_set(&mut self, element: usize) -> usize {
    method merge (line 75) | pub fn merge(&mut self, first_elem: usize, sec_elem: usize) -> usize {
  function test_disjoint_set_union (line 101) | fn test_disjoint_set_union() {

FILE: src/graph/eulerian_path.rs
  function find_eulerian_path (line 17) | pub fn find_eulerian_path(node_count: usize, edge_list: Vec<(usize, usiz...
  type EulerianPathSolver (line 28) | pub struct EulerianPathSolver {
    method new (line 47) | pub fn new(adjacency_list: Vec<Vec<usize>>) -> Self {
    method find_path (line 65) | fn find_path(&mut self) -> Option<Vec<usize>> {
    method initialize_degrees (line 88) | fn initialize_degrees(&mut self) {
    method has_eulerian_path (line 103) | fn has_eulerian_path(&self) -> bool {
    method get_start_node (line 128) | fn get_start_node(&self) -> usize {
    method depth_first_search (line 144) | fn depth_first_search(&mut self, curr_node: usize) {

FILE: src/graph/floyd_warshall.rs
  type Graph (line 5) | type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>;
  function floyd_warshall (line 17) | pub fn floyd_warshall<V: Ord + Copy, E: Ord + Copy + Add<Output = E> + n...
  function add_edge (line 73) | fn add_edge<V: Ord + Copy, E: Ord + Copy>(graph: &mut Graph<V, E>, v1: V...
  function bi_add_edge (line 77) | fn bi_add_edge<V: Ord + Copy, E: Ord + Copy>(graph: &mut Graph<V, E>, v1...
  function single_vertex (line 83) | fn single_vertex() {
  function single_edge (line 94) | fn single_edge() {
  function graph_1 (line 117) | fn graph_1() {

FILE: src/graph/ford_fulkerson.rs
  type FordFulkersonError (line 10) | pub enum FordFulkersonError {
  function bfs (line 30) | fn bfs(graph: &[Vec<usize>], source: usize, sink: usize, parent: &mut [u...
  function validate_ford_fulkerson_input (line 71) | fn validate_ford_fulkerson_input(
  function ford_fulkerson (line 107) | pub fn ford_fulkerson(

FILE: src/graph/graph_enumeration.rs
  type Graph (line 3) | type Graph<Vertex> = BTreeMap<Vertex, Vec<Vertex>>;
  function enumerate_graph (line 13) | pub fn enumerate_graph<V: Ord + Clone>(adj: &Graph<V>) -> Vec<Vec<usize>> {
  function add_edge (line 29) | fn add_edge<V: Ord + Clone>(graph: &mut Graph<V>, a: V, b: V) {
  function string_vertices (line 35) | fn string_vertices() {
  function integer_vertices (line 51) | fn integer_vertices() {

FILE: src/graph/heavy_light_decomposition.rs
  type Adj (line 19) | type Adj = [Vec<usize>];
  type HeavyLightDecomposition (line 21) | pub struct HeavyLightDecomposition {
    method new (line 39) | pub fn new(mut num_vertices: usize) -> Self {
    method dfs (line 48) | fn dfs(&mut self, v: usize, parent: usize, adj: &Adj) -> usize {
    method decompose (line 66) | pub fn decompose(&mut self, root: usize, adj: &Adj) {
    method decompose_path (line 71) | fn decompose_path(&mut self, v: usize, parent: usize, head: usize, adj...
  type LinearCongruenceGenerator (line 94) | struct LinearCongruenceGenerator {
    method new (line 102) | fn new(multiplier: u32, increment: u32, state: u32) -> Self {
    method next (line 109) | fn next(&mut self) -> u32 {
  function get_num_paths (line 116) | fn get_num_paths(
  function single_path (line 141) | fn single_path() {
  function random_tree (line 158) | fn random_tree() {

FILE: src/graph/kosaraju.rs
  type Graph (line 2) | pub struct Graph {
    method new (line 9) | pub fn new(vertices: usize) -> Self {
    method add_edge (line 17) | pub fn add_edge(&mut self, u: usize, v: usize) {
    method dfs (line 22) | pub fn dfs(&self, node: usize, visited: &mut Vec<bool>, stack: &mut Ve...
    method dfs_scc (line 32) | pub fn dfs_scc(&self, node: usize, visited: &mut Vec<bool>, scc: &mut ...
  function kosaraju (line 43) | pub fn kosaraju(graph: &Graph) -> Vec<Vec<usize>> {
  function test_kosaraju_single_sccs (line 71) | fn test_kosaraju_single_sccs() {
  function test_kosaraju_multiple_sccs (line 88) | fn test_kosaraju_multiple_sccs() {
  function test_kosaraju_multiple_sccs1 (line 113) | fn test_kosaraju_multiple_sccs1() {
  function test_kosaraju_no_scc (line 134) | fn test_kosaraju_no_scc() {
  function test_kosaraju_empty_graph (line 150) | fn test_kosaraju_empty_graph() {

FILE: src/graph/lee_breadth_first_search.rs
  function validate (line 5) | fn validate(matrix: &[Vec<i32>], visited: &[Vec<bool>], row: isize, col:...
  function lee (line 11) | pub fn lee(matrix: Vec<Vec<i32>>, source: (usize, usize), destination: (...
  function test_lee_exists (line 61) | fn test_lee_exists() {
  function test_lee_does_not_exist (line 75) | fn test_lee_does_not_exist() {
  function test_source_equals_destination (line 89) | fn test_source_equals_destination() {
  function test_lee_exists_2 (line 103) | fn test_lee_exists_2() {

FILE: src/graph/lowest_common_ancestor.rs
  type LowestCommonAncestorOnline (line 19) | pub struct LowestCommonAncestorOnline {
    method get_parent (line 29) | fn get_parent(&self, v: usize, i: usize) -> usize {
    method num_parents (line 33) | fn num_parents(&self, v: usize) -> usize {
    method new (line 36) | pub fn new(num_vertices: usize) -> Self {
    method fill_sparse_table (line 44) | pub fn fill_sparse_table(
    method get_ancestor (line 69) | pub fn get_ancestor(&self, mut v: usize, mut u: usize) -> usize {
  type LCAQuery (line 101) | pub struct LCAQuery {
  type QueryAnswer (line 107) | pub struct QueryAnswer {
  type LowestCommonAncestorOffline (line 112) | pub struct LowestCommonAncestorOffline {
    method new (line 124) | pub fn new(num_vertices: usize) -> Self {
    method add_query (line 131) | pub fn add_query(&mut self, u: usize, v: usize, query_id: usize) {
    method calculate_answers (line 141) | fn calculate_answers(
    method answer_queries (line 169) | pub fn answer_queries(&mut self, root: usize, adj: &[Vec<usize>]) -> V...
  function small_binary_tree (line 180) | fn small_binary_tree() {

FILE: src/graph/minimum_spanning_tree.rs
  type Edge (line 8) | pub struct Edge {
    method new (line 19) | pub fn new(source: usize, destination: usize, cost: usize) -> Self {
  function kruskal (line 47) | pub fn kruskal(mut edges: Vec<Edge>, num_vertices: usize) -> Option<(usi...

FILE: src/graph/prim.rs
  type Graph (line 5) | type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>;
  function add_edge (line 7) | fn add_edge<V: Ord + Copy, E: Ord + Add + Copy>(graph: &mut Graph<V, E>,...
  function prim (line 13) | pub fn prim<V: Ord + Copy + std::fmt::Debug, E: Ord + Add + Copy + std::...
  function prim_with_start (line 24) | pub fn prim_with_start<V: Ord + Copy, E: Ord + Add + Copy>(
  function empty (line 66) | fn empty() {
  function single_vertex (line 71) | fn single_vertex() {
  function single_edge (line 79) | fn single_edge() {
  function tree_1 (line 88) | fn tree_1() {
  function tree_2 (line 103) | fn tree_2() {
  function tree_3 (line 117) | fn tree_3() {
  function graph_1 (line 129) | fn graph_1() {
  function graph_2 (line 152) | fn graph_2() {
  function graph_3 (line 176) | fn graph_3() {

FILE: src/graph/prufer_code.rs
  type Graph (line 3) | type Graph<V> = BTreeMap<V, Vec<V>>;
  function prufer_encode (line 5) | pub fn prufer_encode<V: Ord + Copy>(tree: &Graph<V>) -> Vec<V> {
  function add_directed_edge (line 34) | fn add_directed_edge<V: Ord + Copy>(tree: &mut Graph<V>, a: V, b: V) {
  function add_edge (line 39) | fn add_edge<V: Ord + Copy>(tree: &mut Graph<V>, a: V, b: V) {
  function prufer_decode (line 44) | pub fn prufer_decode<V: Ord + Copy>(code: &[V], vertex_list: &[V]) -> Gr...
  function equal_graphs (line 78) | fn equal_graphs<V: Ord + Copy>(g1: &mut Graph<V>, g2: &mut Graph<V>) -> ...
  function small_trees (line 89) | fn small_trees() {

FILE: src/graph/strongly_connected_components.rs
  type StronglyConnectedComponents (line 11) | pub struct StronglyConnectedComponents {
    method new (line 54) | pub fn new(mut num_vertices: usize) -> Self {
    method dfs (line 64) | fn dfs(&mut self, v: usize, adj: &[Vec<usize>]) -> u64 {
    method find_components (line 95) | pub fn find_components(&mut self, adj: &[Vec<usize>]) {
  constant NOT_DONE (line 31) | const NOT_DONE: u64 = 1 << 63;
  function set_done (line 34) | fn set_done(vertex_state: &mut u64) {
  function is_in_stack (line 39) | fn is_in_stack(vertex_state: u64) -> bool {
  function is_unvisited (line 44) | fn is_unvisited(vertex_state: u64) -> bool {
  function get_discover_time (line 49) | fn get_discover_time(vertex_state: u64) -> u64 {
  function acyclic (line 110) | fn acyclic() {
  function cycle (line 120) | fn cycle() {
  function dumbbell (line 130) | fn dumbbell() {
  function connected_dumbbell (line 148) | fn connected_dumbbell() {

FILE: src/graph/tarjans_ssc.rs
  type Graph (line 1) | pub struct Graph {
    method new (line 7) | pub fn new(n: usize) -> Self {
    method add_edge (line 14) | pub fn add_edge(&mut self, u: usize, v: usize) {
  function tarjan_scc (line 18) | pub fn tarjan_scc(graph: &Graph) -> Vec<Vec<usize>> {
  function test_tarjan_scc (line 80) | fn test_tarjan_scc() {

FILE: src/graph/topological_sort.rs
  type TopoligicalSortError (line 6) | pub enum TopoligicalSortError {
  type TopologicalSortResult (line 10) | type TopologicalSortResult<Node> = Result<Vec<Node>, TopoligicalSortError>;
  function topological_sort (line 16) | pub fn topological_sort<Node: Hash + Eq + Copy>(
  function is_valid_sort (line 73) | fn is_valid_sort<Node: Eq>(sorted: &[Node], graph: &[(Node, Node)]) -> b...
  function it_works (line 88) | fn it_works() {
  function test_wikipedia_example (line 98) | fn test_wikipedia_example() {
  function test_cyclic_graph (line 117) | fn test_cyclic_graph() {

FILE: src/graph/two_satisfiability.rs
  type Condition (line 3) | pub type Condition = (i64, i64);
  type Graph (line 4) | type Graph = Vec<Vec<usize>>;
  function variable (line 7) | fn variable(var: i64) -> usize {
  function solve_two_satisfiability (line 18) | pub fn solve_two_satisfiability(
  function check_answer (line 53) | fn check_answer(expression: &[Condition], answers: &[bool]) -> bool {
  function basic_test (line 72) | fn basic_test() {
  function big_test (line 95) | fn big_test() {

FILE: src/greedy/minimum_coin_change.rs
  function find_minimum_change (line 170) | pub fn find_minimum_change(denominations: &[i32], value: i32) -> Vec<i32> {
  function test_indian_currency_standard (line 199) | fn test_indian_currency_standard() {
  function test_large_amount (line 207) | fn test_large_amount() {
  function test_zero_value (line 218) | fn test_zero_value() {
  function test_negative_value (line 225) | fn test_negative_value() {
  function test_non_standard_denominations (line 232) | fn test_non_standard_denominations() {
  function test_single_denomination (line 243) | fn test_single_denomination() {
  function test_exact_denomination (line 250) | fn test_exact_denomination() {
  function test_empty_denominations (line 257) | fn test_empty_denominations() {
  function test_unsorted_denominations (line 264) | fn test_unsorted_denominations() {
  function test_usd_currency (line 272) | fn test_usd_currency() {

FILE: src/greedy/smallest_range.rs
  function smallest_range (line 31) | pub fn smallest_range(nums: &[&[i64]]) -> Option<[i64; 2]> {
  function mixed_lists (line 83) | fn mixed_lists() {
  function identical_lists (line 91) | fn identical_lists() {
  function negative_and_positive (line 99) | fn negative_and_positive() {
  function non_overlapping (line 107) | fn non_overlapping() {
  function all_zeros (line 115) | fn all_zeros() {
  function empty_lists (line 123) | fn empty_lists() {
  function single_elements (line 128) | fn single_elements() {
  function single_list (line 133) | fn single_list() {
  function one_empty_among_non_empty (line 138) | fn one_empty_among_non_empty() {

FILE: src/greedy/stable_matching.rs
  function initialize_men (line 3) | fn initialize_men(
  function initialize_women (line 17) | fn initialize_women(
  function precompute_woman_ranks (line 27) | fn precompute_woman_ranks(
  function process_proposal (line 41) | fn process_proposal(
  function woman_prefers_new_man (line 78) | fn woman_prefers_new_man(
  function engage_man (line 88) | fn engage_man(
  function finalize_matches (line 105) | fn finalize_matches(man_engaged: HashMap<String, Option<String>>) -> Has...
  function stable_matching (line 115) | pub fn stable_matching(
  function test_stable_matching_scenario_1 (line 146) | fn test_stable_matching_scenario_1() {
  function test_stable_matching_empty (line 195) | fn test_stable_matching_empty() {
  function test_stable_matching_duplicate_preferences (line 204) | fn test_stable_matching_duplicate_preferences() {
  function test_stable_matching_single_pair (line 225) | fn test_stable_matching_single_pair() {
  function test_woman_prefers_new_man (line 235) | fn test_woman_prefers_new_man() {

FILE: src/machine_learning/cholesky.rs
  function cholesky (line 1) | pub fn cholesky(mat: Vec<f64>, n: usize) -> Vec<f64> {
  function test_cholesky (line 38) | fn test_cholesky() {
  function transpose_matrix (line 53) | fn transpose_matrix(mat: &[f64], n: usize) -> Vec<f64> {
  function matrix_multiply (line 59) | fn matrix_multiply(mat1: &[f64], mat2: &[f64], n: usize) -> Vec<f64> {
  function test_matrix_operations (line 70) | fn test_matrix_operations() {
  function empty_matrix (line 86) | fn empty_matrix() {
  function matrix_with_all_zeros (line 93) | fn matrix_with_all_zeros() {

FILE: src/machine_learning/decision_tree.rs
  type TreeNode (line 6) | enum TreeNode {
  function calculate_entropy (line 21) | fn calculate_entropy(labels: &[f64]) -> f64 {
  function find_best_split (line 57) | fn find_best_split(data: &[(Vec<f64>, f64)], feature_index: usize) -> Op...
  function find_best_split_feature (line 114) | fn find_best_split_feature(
  function get_majority_class (line 144) | fn get_majority_class(labels: &[f64]) -> f64 {
  function build_tree (line 180) | fn build_tree(
  function predict_tree (line 268) | fn predict_tree(tree: &TreeNode, features: &[f64]) -> f64 {
  type DecisionTree (line 288) | pub struct DecisionTree {
    method fit (line 293) | pub fn fit(
    method predict (line 319) | pub fn predict(&self, test_point: &[f64]) -> Option<f64> {
    method predict_batch (line 328) | pub fn predict_batch(&self, test_points: &[Vec<f64>]) -> Vec<Option<f6...
  function decision_tree (line 337) | pub fn decision_tree(
  function test_decision_tree_simple_xor (line 352) | fn test_decision_tree_simple_xor() {
  function test_decision_tree_linearly_separable (line 375) | fn test_decision_tree_linearly_separable() {
  function test_decision_tree_one_feature (line 395) | fn test_decision_tree_one_feature() {
  function test_decision_tree_multiple_classes (line 415) | fn test_decision_tree_multiple_classes() {
  function test_decision_tree_empty_training_data (line 436) | fn test_decision_tree_empty_training_data() {
  function test_decision_tree_empty_features (line 443) | fn test_decision_tree_empty_features() {
  function test_decision_tree_max_depth (line 450) | fn test_decision_tree_max_depth() {
  function test_decision_tree_min_samples_split (line 467) | fn test_decision_tree_min_samples_split() {
  function test_decision_tree_predict_batch (line 484) | fn test_decision_tree_predict_batch() {
  function test_decision_tree_convenience_function (line 506) | fn test_decision_tree_convenience_function() {
  function test_calculate_entropy (line 529) | fn test_calculate_entropy() {
  function test_get_majority_class (line 544) | fn test_get_majority_class() {

FILE: src/machine_learning/k_means.rs
  function get_distance (line 3) | fn get_distance(p1: &(f64, f64), p2: &(f64, f64)) -> f64 {
  function find_nearest (line 10) | fn find_nearest(data_point: &(f64, f64), centroids: &[(f64, f64)]) -> u32 {
  function k_means (line 25) | pub fn k_means(data_points: Vec<(f64, f64)>, n_clusters: usize, max_iter...
  function test_k_means (line 77) | fn test_k_means() {

FILE: src/machine_learning/k_nearest_neighbors.rs
  function euclidean_distance (line 5) | fn euclidean_distance(p1: &[f64], p2: &[f64]) -> f64 {
  function k_nearest_neighbors (line 17) | pub fn k_nearest_neighbors(
  function test_standard_knn (line 58) | fn test_standard_knn() {
  function test_one_dimensional_knn (line 78) | fn test_one_dimensional_knn() {
  function test_knn_empty_data (line 94) | fn test_knn_empty_data() {
  function test_knn_invalid_k (line 102) | fn test_knn_invalid_k() {
  function test_euclidean_distance_different_dimensions (line 116) | fn test_euclidean_distance_different_dimensions() {

FILE: src/machine_learning/linear_regression.rs
  function linear_regression (line 2) | pub fn linear_regression(data_points: Vec<(f64, f64)>) -> Option<(f64, f...
  function test_linear_regression (line 37) | fn test_linear_regression() {
  function test_empty_list_linear_regression (line 45) | fn test_empty_list_linear_regression() {

FILE: src/machine_learning/logistic_regression.rs
  function logistic_regression (line 5) | pub fn logistic_regression(
  function derivative (line 24) | fn derivative(params: &[f64], data_points: &[(Vec<f64>, f64)]) -> Vec<f6...
  function test_logistic_regression_simple (line 51) | fn test_logistic_regression_simple() {
  function test_logistic_regression_extreme_data (line 70) | fn test_logistic_regression_extreme_data() {
  function test_logistic_regression_no_data (line 88) | fn test_logistic_regression_no_data() {

FILE: src/machine_learning/loss_function/average_margin_ranking_loss.rs
  function average_margin_ranking_loss (line 22) | pub fn average_margin_ranking_loss(
  function check_input (line 38) | fn check_input(
  type MarginalRankingLossError (line 61) | pub enum MarginalRankingLossError {

FILE: src/machine_learning/loss_function/hinge_loss.rs
  function hng_loss (line 16) | pub fn hng_loss(y_true: &[f64], y_pred: &[f64]) -> f64 {
  function test_hinge_loss (line 30) | fn test_hinge_loss() {

FILE: src/machine_learning/loss_function/huber_loss.rs
  function huber_loss (line 12) | pub fn huber_loss(y_true: &[f64], y_pred: &[f64], delta: f64) -> Option<...

FILE: src/machine_learning/loss_function/kl_divergence_loss.rs
  function kld_loss (line 13) | pub fn kld_loss(actual: &[f64], predicted: &[f64]) -> f64 {
  function test_kld_loss (line 29) | fn test_kld_loss() {

FILE: src/machine_learning/loss_function/mean_absolute_error_loss.rs
  function mae_loss (line 16) | pub fn mae_loss(predicted: &[f64], actual: &[f64]) -> f64 {
  function test_mae_loss (line 31) | fn test_mae_loss() {

FILE: src/machine_learning/loss_function/mean_squared_error_loss.rs
  function mse_loss (line 16) | pub fn mse_loss(predicted: &[f64], actual: &[f64]) -> f64 {
  function test_mse_loss (line 30) | fn test_mse_loss() {

FILE: src/machine_learning/loss_function/negative_log_likelihood.rs
  function neg_log_likelihood (line 21) | pub fn neg_log_likelihood(
  type NegativeLogLikelihoodLossError (line 47) | pub enum NegativeLogLikelihoodLossError {
  function are_all_values_in_range (line 53) | fn are_all_values_in_range(values: &[f64]) -> bool {

FILE: src/machine_learning/naive_bayes.rs
  type ClassStatistics (line 7) | pub struct ClassStatistics {
  function calculate_class_statistics (line 14) | fn calculate_class_statistics(
  function gaussian_log_pdf (line 70) | fn gaussian_log_pdf(x: f64, mean: f64, variance: f64) -> f64 {
  function train_naive_bayes (line 77) | pub fn train_naive_bayes(training_data: Vec<(Vec<f64>, f64)>) -> Option<...
  function predict_naive_bayes (line 124) | pub fn predict_naive_bayes(model: &[ClassStatistics], test_point: &[f64]...
  function naive_bayes (line 159) | pub fn naive_bayes(training_data: Vec<(Vec<f64>, f64)>, test_point: Vec<...
  function test_naive_bayes_simple_classification (line 169) | fn test_naive_bayes_simple_classification() {
  function test_naive_bayes_one_dimensional (line 191) | fn test_naive_bayes_one_dimensional() {
  function test_naive_bayes_empty_training_data (line 211) | fn test_naive_bayes_empty_training_data() {
  function test_naive_bayes_empty_test_point (line 219) | fn test_naive_bayes_empty_test_point() {
  function test_naive_bayes_dimension_mismatch (line 227) | fn test_naive_bayes_dimension_mismatch() {
  function test_naive_bayes_inconsistent_feature_dimensions (line 235) | fn test_naive_bayes_inconsistent_feature_dimensions() {
  function test_naive_bayes_multiple_classes (line 246) | fn test_naive_bayes_multiple_classes() {
  function test_train_and_predict_separately (line 270) | fn test_train_and_predict_separately() {

FILE: src/machine_learning/optimization/adam.rs
  type Adam (line 41) | pub struct Adam {
    method new (line 51) | pub fn new(
    method step (line 67) | pub fn step(&mut self, gradients: &[f64]) -> Vec<f64> {
  function test_adam_init_default_values (line 92) | fn test_adam_init_default_values() {
  function test_adam_init_custom_lr_value (line 104) | fn test_adam_init_custom_lr_value() {
  function test_adam_init_custom_betas_value (line 116) | fn test_adam_init_custom_betas_value() {
  function test_adam_init_custom_epsilon_value (line 128) | fn test_adam_init_custom_epsilon_value() {
  function test_adam_init_all_custom_values (line 140) | fn test_adam_init_all_custom_values() {
  function test_adam_step_default_params (line 152) | fn test_adam_step_default_params() {
  function test_adam_step_custom_params (line 174) | fn test_adam_step_custom_params() {
  function test_adam_step_empty_gradients_array (line 197) | fn test_adam_step_empty_gradients_array() {
  function test_adam_step_iteratively_until_convergence_with_default_params (line 208) | fn test_adam_step_iteratively_until_convergence_with_default_params() {
  function test_adam_step_iteratively_until_convergence_with_custom_params (line 249) | fn test_adam_step_iteratively_until_convergence_with_custom_params() {

FILE: src/machine_learning/optimization/gradient_descent.rs
  function gradient_descent (line 25) | pub fn gradient_descent(
  function test_gradient_descent_optimized (line 46) | fn test_gradient_descent_optimized() {
  function test_gradient_descent_unoptimized (line 67) | fn test_gradient_descent_unoptimized() {

FILE: src/machine_learning/optimization/momentum.rs
  function momentum (line 29) | pub fn momentum(
  function test_momentum_optimized (line 56) | fn test_momentum_optimized() {
  function test_momentum_unoptimized (line 83) | fn test_momentum_unoptimized() {
  function test_momentum_faster_than_gd (line 110) | fn test_momentum_faster_than_gd() {

FILE: src/machine_learning/perceptron.rs
  function perceptron (line 4) | pub fn perceptron(
  function predict (line 46) | fn predict(weights: &[f64], bias: f64, features: &[f64]) -> f64 {
  function classify (line 62) | pub fn classify(weights: &[f64], bias: f64, features: &[f64]) -> Option<...
  function test_perceptron_linearly_separable (line 79) | fn test_perceptron_linearly_separable() {
  function test_perceptron_xor_like (line 102) | fn test_perceptron_xor_like() {
  function test_perceptron_single_feature (line 118) | fn test_perceptron_single_feature() {
  function test_perceptron_empty_data (line 142) | fn test_perceptron_empty_data() {
  function test_perceptron_empty_features (line 148) | fn test_perceptron_empty_features() {
  function test_perceptron_zero_iterations (line 155) | fn test_perceptron_zero_iterations() {
  function test_classify_empty_weights (line 167) | fn test_classify_empty_weights() {
  function test_classify_empty_features (line 173) | fn test_classify_empty_features() {
  function test_classify_mismatched_dimensions (line 179) | fn test_classify_mismatched_dimensions() {
  function test_perceptron_different_learning_rates (line 185) | fn test_perceptron_different_learning_rates() {
  function test_perceptron_with_bias (line 210) | fn test_perceptron_with_bias() {

FILE: src/machine_learning/principal_component_analysis.rs
  function compute_means (line 7) | fn compute_means(data: &[Vec<f64>]) -> Vec<f64> {
  function center_data (line 30) | fn center_data(data: &[Vec<f64>], means: &[f64]) -> Vec<Vec<f64>> {
  function compute_covariance_matrix (line 43) | fn compute_covariance_matrix(centered_data: &[Vec<f64>]) -> Vec<f64> {
  function power_iteration (line 70) | fn power_iteration(matrix: &[f64], n: usize, max_iter: usize, tolerance:...
  function deflate_matrix (line 121) | fn deflate_matrix(matrix: &[f64], eigenvector: &[f64], eigenvalue: f64, ...
  function principal_component_analysis (line 135) | pub fn principal_component_analysis(
  function test_pca_simple (line 199) | fn test_pca_simple() {
  function test_pca_empty_data (line 222) | fn test_pca_empty_data() {
  function test_pca_empty_features (line 229) | fn test_pca_empty_features() {
  function test_pca_invalid_num_components (line 236) | fn test_pca_invalid_num_components() {
  function test_pca_preserves_dimensions (line 247) | fn test_pca_preserves_dimensions() {
  function test_pca_reconstruction_variance (line 263) | fn test_pca_reconstruction_variance() {
  function test_center_data (line 286) | fn test_center_data() {
  function test_compute_means (line 302) | fn test_compute_means() {
  function test_power_iteration (line 314) | fn test_power_iteration() {

FILE: src/machine_learning/random_forest.rs
  function train_tree (line 6) | fn train_tree(
  type RandomForest (line 52) | pub struct RandomForest {
    method fit (line 59) | pub fn fit(
    method predict (line 134) | pub fn predict(&self, test_point: &[f64]) -> Option<f64> {
    method predict_batch (line 186) | pub fn predict_batch(&self, test_points: &[Vec<f64>]) -> Vec<Option<f6...
  function random_forest (line 195) | pub fn random_forest(
  function test_random_forest_linearly_separable (line 218) | fn test_random_forest_linearly_separable() {
  function test_random_forest_xor (line 238) | fn test_random_forest_xor() {
  function test_random_forest_multiple_classes (line 265) | fn test_random_forest_multiple_classes() {
  function test_random_forest_one_feature (line 286) | fn test_random_forest_one_feature() {
  function test_random_forest_empty_training_data (line 306) | fn test_random_forest_empty_training_data() {
  function test_random_forest_empty_features (line 313) | fn test_random_forest_empty_features() {
  function test_random_forest_predict_batch (line 320) | fn test_random_forest_predict_batch() {
  function test_random_forest_custom_max_features (line 342) | fn test_random_forest_custom_max_features() {
  function test_random_forest_convenience_function (line 360) | fn test_random_forest_convenience_function() {
  function test_random_forest_single_tree (line 383) | fn test_random_forest_single_tree() {
  function test_random_forest_empty_test_point (line 406) | fn test_random_forest_empty_test_point() {
  function test_random_forest_different_num_trees (line 424) | fn test_random_forest_different_num_trees() {

FILE: src/machine_learning/support_vector_classifier.rs
  type Kernel (line 31) | pub enum Kernel {
  type SVC (line 43) | pub struct SVC {
    method new (line 93) | pub fn new(kernel: Kernel, regularization: f64) -> Result<Self, SVCErr...
    method kernel_function (line 115) | fn kernel_function(&self, v1: &Array1<f64>, v2: &Array1<f64>) -> f64 {
    method fit (line 145) | pub fn fit(
    method solve_dual (line 179) | fn solve_dual(&self, n: usize) -> Array1<f64> {
    method calculate_offset (line 256) | fn calculate_offset(&self, n: usize) -> f64 {
    method predict (line 313) | pub fn predict(&self, observation: &Array1<f64>) -> f64 {
    method n_support_vectors (line 331) | pub fn n_support_vectors(&self) -> usize {
  type SVCError (line 54) | pub enum SVCError {
    method fmt (line 62) | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
  function test_linear_kernel_simple (line 342) | fn test_linear_kernel_simple() {
  function test_rbf_kernel (line 360) | fn test_rbf_kernel() {
  function test_invalid_gamma (line 378) | fn test_invalid_gamma() {
  function test_invalid_regularization (line 387) | fn test_invalid_regularization() {
  function test_empty_data (line 396) | fn test_empty_data() {
  function test_mismatched_dimensions (line 403) | fn test_mismatched_dimensions() {
  function test_support_vectors_count (line 412) | fn test_support_vectors_count() {

FILE: src/math/abs.rs
  function abs (line 5) | pub fn abs<T>(num: T) -> T
  function test_negative_number_i32 (line 20) | fn test_negative_number_i32() {
  function test_negative_number_f64 (line 25) | fn test_negative_number_f64() {
  function zero (line 30) | fn zero() {
  function positive_number (line 35) | fn positive_number() {

FILE: src/math/aliquot_sum.rs
  function aliquot_sum (line 9) | pub fn aliquot_sum(number: u64) -> u64 {
  function panics_if_input_is_zero (line 53) | fn panics_if_input_is_zero() {

FILE: src/math/amicable_numbers.rs
  function amicable_pairs_under_n (line 7) | pub fn amicable_pairs_under_n(n: u32) -> Option<Vec<(u32, u32)>> {
  function test_amicable_numbers_below_n (line 40) | pub fn test_amicable_numbers_below_n() {

FILE: src/math/area_of_polygon.rs
  type Point (line 17) | pub struct Point {
  function area_of_polygon (line 28) | pub fn area_of_polygon(fig: &[Point]) -> f64 {
  function test_area_triangle (line 53) | fn test_area_triangle() {
  function test_area_square (line 67) | fn test_area_square() {
  function test_area_hexagon (line 82) | fn test_area_hexagon() {

FILE: src/math/area_under_curve.rs
  function area_under_curve (line 1) | pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step...
  function test_linear_func (line 29) | fn test_linear_func() {
  function test_quadratic_func (line 34) | fn test_quadratic_func() {
  function test_zero_length (line 42) | fn test_zero_length() {
  function test_reverse (line 47) | fn test_reverse() {

FILE: src/math/armstrong_number.rs
  function is_armstrong_number (line 1) | pub fn is_armstrong_number(number: u32) -> bool {
  function one_digit_armstrong_number (line 25) | fn one_digit_armstrong_number() {
  function two_digit_numbers_are_not_armstrong_numbers (line 29) | fn two_digit_numbers_are_not_armstrong_numbers() {
  function three_digit_armstrong_number (line 33) | fn three_digit_armstrong_number() {
  function three_digit_non_armstrong_number (line 37) | fn three_digit_non_armstrong_number() {
  function big_armstrong_number (line 41) | fn big_armstrong_number() {

FILE: src/math/average.rs
  function sum (line 17) | fn sum<T: Num + Copy>(sequence: Vec<T>) -> T {
  function mean (line 25) | pub fn mean<T: Num + Copy + num_traits::FromPrimitive>(sequence: Vec<T>)...
  function mean_of_two (line 33) | fn mean_of_two<T: Num + Copy>(a: T, b: T) -> T {
  function median (line 42) | pub fn median<T: Num + Copy + PartialOrd>(mut sequence: Vec<T>) -> Optio...
  function histogram (line 56) | fn histogram<T: Eq + std::hash::Hash>(sequence: Vec<T>) -> HashMap<T, us...
  function mode (line 67) | pub fn mode<T: Eq + std::hash::Hash>(sequence: Vec<T>) -> Option<HashSet...
  function median_test (line 85) | fn median_test() {
  function mode_test (line 95) | fn mode_test() {
  function mean_test (line 111) | fn mean_test() {

FILE: src/math/baby_step_giant_step.rs
  function baby_step_giant_step (line 13) | pub fn baby_step_giant_step(a: usize, b: usize, n: usize) -> Option<usiz...
  function small_numbers (line 42) | fn small_numbers() {
  function primitive_root_tests (line 51) | fn primitive_root_tests() {
  function random_numbers (line 63) | fn random_numbers() {
  function no_solution (line 78) | fn no_solution() {

FILE: src/math/bell_numbers.rs
  function n_choose_r (line 6) | fn n_choose_r(n: u32, r: u32) -> BigUint {
  type MemTable (line 26) | struct MemTable {
    method new (line 31) | const fn new() -> Self {
    method get (line 35) | fn get(&self, n: usize) -> Option<BigUint> {
    method set (line 49) | fn set(&mut self, n: usize, b: BigUint) {
    method capacity (line 54) | fn capacity(&self) -> usize {
    method resize (line 59) | fn resize(&mut self, new_size: usize) {
  function bell_number (line 69) | pub fn bell_number(n: u32) -> BigUint {
  function test_choose_zero (line 109) | fn test_choose_zero() {
  function test_combination (line 116) | fn test_combination() {
  function test_bell_numbers (line 131) | fn test_bell_numbers() {

FILE: src/math/binary_exponentiation.rs
  function binary_exponentiation (line 13) | pub fn binary_exponentiation(mut n: u64, mut p: u32) -> u64 {
  function basic (line 30) | fn basic() {
  function up_to_ten (line 41) | fn up_to_ten() {

FILE: src/math/binomial_coefficient.rs
  function binom (line 26) | pub fn binom(n: u64, k: u64) -> BigInt {
  function test_binom_5_2 (line 39) | fn test_binom_5_2() {
  function test_binom_10_5 (line 44) | fn test_binom_10_5() {
  function test_binom_0_0 (line 49) | fn test_binom_0_0() {
  function test_binom_large_n_small_k (line 54) | fn test_binom_large_n_small_k() {
  function test_binom_random_1 (line 59) | fn test_binom_random_1() {
  function test_binom_random_2 (line 65) | fn test_binom_random_2() {
  function test_binom_random_3 (line 71) | fn test_binom_random_3() {

FILE: src/math/catalan_numbers.rs
  constant MOD (line 12) | const MOD: i64 = 1000000007;
  constant MAX (line 13) | const MAX: usize = 1005;
  function init_catalan (line 15) | pub fn init_catalan() -> Vec<i64> {
  function test_catalan (line 38) | fn test_catalan() {

FILE: src/math/ceil.rs
  function ceil (line 4) | pub fn ceil(x: f64) -> f64 {
  function positive_decimal (line 18) | fn positive_decimal() {
  function positive_decimal_with_small_number (line 24) | fn positive_decimal_with_small_number() {
  function positive_integer (line 30) | fn positive_integer() {
  function negative_decimal (line 36) | fn negative_decimal() {
  function negative_decimal_with_small_number (line 42) | fn negative_decimal_with_small_number() {
  function negative_integer (line 48) | fn negative_integer() {
  function zero (line 54) | fn zero() {

FILE: src/math/chinese_remainder_theorem.rs
  function mod_inv (line 3) | fn mod_inv(x: i32, n: i32) -> Option<i32> {
  function chinese_remainder_theorem (line 12) | pub fn chinese_remainder_theorem(residues: &[i32], modulli: &[i32]) -> O...
  function basic (line 29) | fn basic() {

FILE: src/math/collatz_sequence.rs
  function sequence (line 2) | pub fn sequence(mut n: usize) -> Option<Vec<usize>> {
  function validity_check (line 24) | fn validity_check() {

FILE: src/math/combinations.rs
  function combinations (line 2) | pub fn combinations(n: i64, k: i64) -> i64 {
  function test_combinations_10_choose_5 (line 25) | fn test_combinations_10_choose_5() {
  function test_combinations_6_choose_3 (line 31) | fn test_combinations_6_choose_3() {
  function test_combinations_20_choose_5 (line 37) | fn test_combinations_20_choose_5() {
  function test_combinations_invalid_input (line 44) | fn test_combinations_invalid_input() {

FILE: src/math/cross_entropy_loss.rs
  function cross_entropy_loss (line 19) | pub fn cross_entropy_loss(actual: &[f64], predicted: &[f64]) -> f64 {
  function test_cross_entropy_loss (line 32) | fn test_cross_entropy_loss() {

FILE: src/math/decimal_to_fraction.rs
  function decimal_to_fraction (line 1) | pub fn decimal_to_fraction(decimal: f64) -> (i64, i64) {
  function test_decimal_to_fraction_1 (line 39) | fn test_decimal_to_fraction_1() {
  function test_decimal_to_fraction_2 (line 44) | fn test_decimal_to_fraction_2() {
  function test_decimal_to_fraction_3 (line 49) | fn test_decimal_to_fraction_3() {
  function test_decimal_to_fraction_4 (line 54) | fn test_decimal_to_fraction_4() {
  function test_decimal_to_fraction_5 (line 59) | fn test_decimal_to_fraction_5() {
  function test_decimal_to_fraction_6 (line 64) | fn test_decimal_to_fraction_6() {

FILE: src/math/doomsday.rs
  constant T (line 1) | const T: [i32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
  function doomsday (line 3) | pub fn doomsday(y: i32, m: i32, d: i32) -> i32 {
  function get_week_day (line 8) | pub fn get_week_day(y: i32, m: i32, d: i32) -> String {
  function doomsday_test (line 29) | fn doomsday_test() {

FILE: src/math/elliptic_curve.rs
  type EllipticCurve (line 27) | pub struct EllipticCurve<F, const A: i64, const B: i64> {
  function infinity (line 35) | pub fn infinity() -> Self {
  function new (line 48) | pub fn new(x: impl Into<F>, y: impl Into<F>) -> Option<Self> {
  function is_infinity (line 64) | pub fn is_infinity(&self) -> bool {
  function x (line 69) | pub fn x(&self) -> &F {
  function y (line 74) | pub fn y(&self) -> &F {
  function discriminant (line 79) | pub const fn discriminant() -> i64 {
  function contains (line 86) | fn contains(x: F, y: F) -> bool {
  function check_invariants (line 90) | const fn check_invariants() {
  function points (line 101) | pub fn points() -> impl Iterator<Item = Self> {
  function cardinality (line 109) | pub fn cardinality() -> usize {
  function cardinality_counted_table (line 123) | pub fn cardinality_counted_table() -> usize {
  function cardinality_counted_legendre (line 156) | pub fn cardinality_counted_legendre() -> usize {
  type Output (line 174) | type Output = Self;
  method add (line 176) | fn add(self, p: Self) -> Self::Output {
  type Output (line 199) | type Output = Self;
  method neg (line 201) | fn neg(self) -> Self::Output {
  type Output (line 212) | type Output = Self;
  method sub (line 214) | fn sub(self, p: Self) -> Self::Output {
  function fmt (line 221) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  method eq (line 232) |
Condensed preview — 438 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,034K chars).
[
  {
    "path": ".gitconfig",
    "chars": 33,
    "preview": "[core]\n    hooksPath = git_hooks\n"
  },
  {
    "path": ".github/CODEOWNERS",
    "chars": 11,
    "preview": "* @imp2002\n"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 233,
    "preview": "---\nversion: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/.github/workflows/\"\n    schedule:\n     "
  },
  {
    "path": ".github/pull_request_template.md",
    "chars": 1507,
    "preview": "# Pull Request Template\n\n## Description\n\nPlease include a summary of the change and which issue (if any) is fixed.\nA bri"
  },
  {
    "path": ".github/workflows/build.yml",
    "chars": 621,
    "preview": "name: build\n\n'on':\n  pull_request:\n  workflow_dispatch:\n  schedule:\n    - cron: '51 2 * * 4'\n\npermissions:\n  contents: r"
  },
  {
    "path": ".github/workflows/code_ql.yml",
    "chars": 792,
    "preview": "---\nname: code_ql\n\n'on':\n  workflow_dispatch:\n  push:\n    branches:\n      - master\n  pull_request:\n  schedule:\n    - cro"
  },
  {
    "path": ".github/workflows/directory_workflow.yml",
    "chars": 921,
    "preview": "name: build_directory_md\non:\n  push:\n    branches: [master]\n\npermissions:\n  contents: read\n\njobs:\n  MainSequence:\n    na"
  },
  {
    "path": ".github/workflows/scripts/build_directory/Cargo.toml",
    "chars": 184,
    "preview": "[package]\nname = \"build_directory\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://"
  },
  {
    "path": ".github/workflows/scripts/build_directory/src/lib.rs",
    "chars": 4058,
    "preview": "use std::{\n    error::Error,\n    fs,\n    path::{Path, PathBuf},\n};\n\nstatic URL_BASE: &str = \"https://github.com/TheAlgor"
  },
  {
    "path": ".github/workflows/scripts/build_directory/src/main.rs",
    "chars": 504,
    "preview": "use std::{fs::File, io::Write, path::Path};\n\nuse build_directory::build_directory_md;\nfn main() -> Result<(), std::io::E"
  },
  {
    "path": ".github/workflows/stale.yml",
    "chars": 1426,
    "preview": "name: 'Close stale issues and PRs'\non:\n  schedule:\n    - cron: '0 0 * * *'\npermissions:\n  contents: read\n\njobs:\n  stale:"
  },
  {
    "path": ".github/workflows/upload_coverage_report.yml",
    "chars": 1213,
    "preview": "---\nname: upload_coverage_report\n\n# yamllint disable-line rule:truthy\non:\n  workflow_dispatch:\n  push:\n    branches:\n   "
  },
  {
    "path": ".gitignore",
    "chars": 67,
    "preview": "\n/target\n**/*.rs.bk\n\n/target\n**/*.rs.bk\nCargo.lock\n/.idea/\n.vscode\n"
  },
  {
    "path": ".gitpod.Dockerfile",
    "chars": 60,
    "preview": "FROM gitpod/workspace-rust:2024-06-05-14-45-28\n\nUSER gitpod\n"
  },
  {
    "path": ".gitpod.yml",
    "chars": 125,
    "preview": "---\nimage:\n  file: .gitpod.Dockerfile\n\ntasks:\n  - init: cargo build\n\nvscode:\n  extensions:\n    - rust-lang.rust-analyzer"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 866,
    "preview": "# The Algorithms: Rust\n\nThis project aims at showcasing common algorithms implemented in `Rust`, with an accent on idiom"
  },
  {
    "path": "Cargo.toml",
    "chars": 8639,
    "preview": "[package]\nname = \"the_algorithms_rust\"\nversion = \"0.1.0\"\nedition = \"2021\"\nauthors = [\"Anshul Malik <malikanshul29@gmail."
  },
  {
    "path": "DIRECTORY.md",
    "chars": 41533,
    "preview": "# List of all files\n\n## src\n  * Backtracking\n    * [All Combinations of Size K](https://github.com/TheAlgorithms/Rust/bl"
  },
  {
    "path": "LICENSE",
    "chars": 1071,
    "preview": "MIT License\n\nCopyright (c) 2019 The Algorithms\n\nPermission is hereby granted, free of charge, to any person obtaining a "
  },
  {
    "path": "README.md",
    "chars": 1587,
    "preview": "<div align=\"center\">\n<!-- Title: -->\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Rust_programmin"
  },
  {
    "path": "clippy.toml",
    "chars": 43,
    "preview": "allowed-duplicate-crates = [\n    \"glam\",\n]\n"
  },
  {
    "path": "git_hooks/pre-commit",
    "chars": 21,
    "preview": "cargo fmt\ncargo test\n"
  },
  {
    "path": "src/backtracking/all_combination_of_size_k.rs",
    "chars": 3557,
    "preview": "//! This module provides a function to generate all possible combinations\n//! of `k` numbers out of `0...n-1` using a ba"
  },
  {
    "path": "src/backtracking/graph_coloring.rs",
    "chars": 12810,
    "preview": "//! This module provides functionality for generating all possible colorings of a undirected (or directed) graph\n//! giv"
  },
  {
    "path": "src/backtracking/hamiltonian_cycle.rs",
    "chars": 10758,
    "preview": "//! This module provides functionality to find a Hamiltonian cycle in a directed or undirected graph.\n//! Source: [Wikip"
  },
  {
    "path": "src/backtracking/knight_tour.rs",
    "chars": 6082,
    "preview": "//! This module contains the implementation of the Knight's Tour problem.\n//!\n//! The Knight's Tour is a classic chess p"
  },
  {
    "path": "src/backtracking/mod.rs",
    "chars": 623,
    "preview": "mod all_combination_of_size_k;\nmod graph_coloring;\nmod hamiltonian_cycle;\nmod knight_tour;\nmod n_queens;\nmod parentheses"
  },
  {
    "path": "src/backtracking/n_queens.rs",
    "chars": 6396,
    "preview": "//! This module provides functionality to solve the N-Queens problem.\n//!\n//! The N-Queens problem is a classic chessboa"
  },
  {
    "path": "src/backtracking/parentheses_generator.rs",
    "chars": 2677,
    "preview": "/// Generates all combinations of well-formed parentheses given a non-negative integer `n`.\n///\n/// This function uses b"
  },
  {
    "path": "src/backtracking/permutations.rs",
    "chars": 4065,
    "preview": "//! This module provides a function to generate all possible distinct permutations\n//! of a given collection of integers"
  },
  {
    "path": "src/backtracking/rat_in_maze.rs",
    "chars": 12196,
    "preview": "//! This module contains the implementation of the Rat in Maze problem.\n//!\n//! The Rat in Maze problem is a classic alg"
  },
  {
    "path": "src/backtracking/subset_sum.rs",
    "chars": 2282,
    "preview": "//! This module provides functionality to check if there exists a subset of a given set of integers\n//! that sums to a t"
  },
  {
    "path": "src/backtracking/sudoku.rs",
    "chars": 5325,
    "preview": "//! A Rust implementation of Sudoku solver using Backtracking.\n//!\n//! This module provides functionality to solve Sudok"
  },
  {
    "path": "src/big_integer/fast_factorial.rs",
    "chars": 2871,
    "preview": "// Algorithm created by Peter Borwein in 1985\n// https://doi.org/10.1016/0196-6774(85)90006-9\n\nuse crate::math::sieve_of"
  },
  {
    "path": "src/big_integer/mod.rs",
    "chars": 194,
    "preview": "#![cfg(feature = \"big-math\")]\n\nmod fast_factorial;\nmod multiply;\nmod poly1305;\n\npub use self::fast_factorial::fast_facto"
  },
  {
    "path": "src/big_integer/multiply.rs",
    "chars": 2362,
    "preview": "/// Performs long multiplication on string representations of non-negative numbers.\npub fn multiply(num1: &str, num2: &s"
  },
  {
    "path": "src/big_integer/poly1305.rs",
    "chars": 2842,
    "preview": "use num_bigint::BigUint;\nuse num_traits::Num;\nuse num_traits::Zero;\n\nmacro_rules! hex_uint {\n    ($a:literal) => {\n     "
  },
  {
    "path": "src/bit_manipulation/binary_coded_decimal.rs",
    "chars": 4185,
    "preview": "//! Binary Coded Decimal (BCD) conversion\n//!\n//! This module provides a function to convert decimal integers to Binary "
  },
  {
    "path": "src/bit_manipulation/binary_count_trailing_zeros.rs",
    "chars": 3149,
    "preview": "/// Counts the number of trailing zeros in the binary representation of a number\n///\n/// # Arguments\n///\n/// * `num` - T"
  },
  {
    "path": "src/bit_manipulation/binary_shifts.rs",
    "chars": 15331,
    "preview": "//! Binary Shift Operations\n//!\n//! This module provides implementations of various binary shift operations with\n//! bin"
  },
  {
    "path": "src/bit_manipulation/counting_bits.rs",
    "chars": 1745,
    "preview": "//! This module implements a function to count the number of set bits (1s)\n//! in the binary representation of an unsign"
  },
  {
    "path": "src/bit_manipulation/find_missing_number.rs",
    "chars": 3474,
    "preview": "/// Finds the missing number in a slice of consecutive integers.\n///\n/// This function uses XOR bitwise operation to fin"
  },
  {
    "path": "src/bit_manipulation/find_previous_power_of_two.rs",
    "chars": 6080,
    "preview": "//! Previous Power of Two\n//!\n//! This module provides a function to find the largest power of two that is less than\n//!"
  },
  {
    "path": "src/bit_manipulation/find_unique_number.rs",
    "chars": 2292,
    "preview": "/// Finds the unique number in a slice where every other element appears twice.\n///\n/// This function uses the XOR bitwi"
  },
  {
    "path": "src/bit_manipulation/hamming_distance.rs",
    "chars": 3512,
    "preview": "//! Hamming Distance\n//!\n//! This module implements the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distanc"
  },
  {
    "path": "src/bit_manipulation/highest_set_bit.rs",
    "chars": 1260,
    "preview": "//! This module provides a function to find the position of the most significant bit (MSB)\n//! set to 1 in a given posit"
  },
  {
    "path": "src/bit_manipulation/is_power_of_two.rs",
    "chars": 8051,
    "preview": "//! Power of Two Check\n//!\n//! This module provides a function to determine if a given positive integer is a power of tw"
  },
  {
    "path": "src/bit_manipulation/mod.rs",
    "chars": 1376,
    "preview": "mod binary_coded_decimal;\nmod binary_count_trailing_zeros;\nmod binary_shifts;\nmod counting_bits;\nmod find_missing_number"
  },
  {
    "path": "src/bit_manipulation/n_bits_gray_code.rs",
    "chars": 1891,
    "preview": "/// Custom error type for Gray code generation.\n#[derive(Debug, PartialEq)]\npub enum GrayCodeError {\n    ZeroBitCount,\n}"
  },
  {
    "path": "src/bit_manipulation/reverse_bits.rs",
    "chars": 3862,
    "preview": "//! This module provides a function to reverse the bits of a 32-bit unsigned integer.\n//!\n//! The algorithm works by ite"
  },
  {
    "path": "src/bit_manipulation/rightmost_set_bit.rs",
    "chars": 6712,
    "preview": "/// Finds the index (position) of the rightmost set bit in a number.\n///\n/// The index is 1-based, where position 1 is t"
  },
  {
    "path": "src/bit_manipulation/sum_of_two_integers.rs",
    "chars": 1586,
    "preview": "//! This module provides a function to add two integers without using the `+` operator.\n//! It relies on bitwise operati"
  },
  {
    "path": "src/bit_manipulation/swap_odd_even_bits.rs",
    "chars": 2214,
    "preview": "/// Swaps odd and even bits in an integer.\n///\n/// This function separates the even bits (0, 2, 4, 6, etc.) and odd bits"
  },
  {
    "path": "src/bit_manipulation/twos_complement.rs",
    "chars": 4465,
    "preview": "//! Two's Complement Representation\n//!\n//! Two's complement is a mathematical operation on binary numbers and a binary "
  },
  {
    "path": "src/ciphers/README.md",
    "chars": 4512,
    "preview": "## Ciphers\n\n### [Caesar](./caesar.rs)\n![alt text][caesar]\nIn cryptography, a **Caesar cipher**, also known as Caesar's c"
  },
  {
    "path": "src/ciphers/aes.rs",
    "chars": 28176,
    "preview": "const AES_WORD_SIZE: usize = 4;\nconst AES_BLOCK_SIZE: usize = 16;\nconst AES_NUM_BLOCK_WORDS: usize = AES_BLOCK_SIZE / AE"
  },
  {
    "path": "src/ciphers/affine_cipher.rs",
    "chars": 13672,
    "preview": "//! Affine Cipher\n//!\n//! The affine cipher is a type of monoalphabetic substitution cipher where each\n//! character in "
  },
  {
    "path": "src/ciphers/another_rot13.rs",
    "chars": 929,
    "preview": "pub fn another_rot13(text: &str) -> String {\n    let input = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n   "
  },
  {
    "path": "src/ciphers/baconian_cipher.rs",
    "chars": 2320,
    "preview": "// Author : cyrixninja\n//Program to encode and decode Baconian or Bacon's Cipher\n//Wikipedia reference : https://en.wiki"
  },
  {
    "path": "src/ciphers/base16.rs",
    "chars": 6920,
    "preview": "//! Base16 encoding and decoding implementation.\n//!\n//! Base16, also known as hexadecimal encoding, represents binary d"
  },
  {
    "path": "src/ciphers/base32.rs",
    "chars": 8219,
    "preview": "//! Base32 encoding and decoding implementation.\n//!\n//! Base32 is a binary-to-text encoding scheme that represents bina"
  },
  {
    "path": "src/ciphers/base64.rs",
    "chars": 9530,
    "preview": "/*\n    A Rust implementation of a base64 encoder and decoder.\n    Written from scratch.\n*/\n\n// The charset and padding u"
  },
  {
    "path": "src/ciphers/base85.rs",
    "chars": 5606,
    "preview": "//! Base85 (Ascii85) encoding and decoding\n//!\n//! Ascii85 is a form of binary-to-text encoding developed by Adobe Syste"
  },
  {
    "path": "src/ciphers/blake2b.rs",
    "chars": 10261,
    "preview": "// For specification go to https://www.rfc-editor.org/rfc/rfc7693\n\nuse std::cmp::{max, min};\nuse std::convert::{TryFrom,"
  },
  {
    "path": "src/ciphers/caesar.rs",
    "chars": 4201,
    "preview": "const ERROR_MESSAGE: &str = \"Rotation must be in the range [0, 25]\";\nconst ALPHABET_LENGTH: u8 = b'z' - b'a' + 1;\n\n/// E"
  },
  {
    "path": "src/ciphers/chacha.rs",
    "chars": 5756,
    "preview": "macro_rules! quarter_round {\n    ($a:expr,$b:expr,$c:expr,$d:expr) => {\n        $a = $a.wrapping_add($b);\n        $d = ("
  },
  {
    "path": "src/ciphers/diffie_hellman.rs",
    "chars": 14908,
    "preview": "// Based on the TheAlgorithms/Python\n// RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for\n// Internet"
  },
  {
    "path": "src/ciphers/hashing_traits.rs",
    "chars": 3235,
    "preview": "pub trait Hasher<const DIGEST_BYTES: usize> {\n    /// return a new instance with default parameters\n    fn new_default()"
  },
  {
    "path": "src/ciphers/hill_cipher.rs",
    "chars": 11231,
    "preview": "//! Hill Cipher\n//!\n//! The Hill Cipher is a polygraphic substitution cipher based on linear algebra.\n//!\n//! # Algorith"
  },
  {
    "path": "src/ciphers/kernighan.rs",
    "chars": 482,
    "preview": "pub fn kernighan(n: u32) -> i32 {\n    let mut count = 0;\n    let mut n = n;\n\n    while n > 0 {\n        n = n & (n - 1);\n"
  },
  {
    "path": "src/ciphers/mod.rs",
    "chars": 1935,
    "preview": "mod aes;\nmod affine_cipher;\nmod another_rot13;\nmod baconian_cipher;\nmod base16;\nmod base32;\nmod base64;\nmod base85;\nmod "
  },
  {
    "path": "src/ciphers/morse_code.rs",
    "chars": 6125,
    "preview": "use std::collections::HashMap;\nuse std::io;\n\nconst UNKNOWN_CHARACTER: &str = \"........\";\nconst _UNKNOWN_MORSE_CHARACTER:"
  },
  {
    "path": "src/ciphers/polybius.rs",
    "chars": 3698,
    "preview": "/// Encode an ASCII string into its location in a Polybius square.\n/// Only alphabetical characters are encoded.\npub fn "
  },
  {
    "path": "src/ciphers/rail_fence.rs",
    "chars": 1198,
    "preview": "// wiki: https://en.wikipedia.org/wiki/Rail_fence_cipher\npub fn rail_fence_encrypt(plain_text: &str, key: usize) -> Stri"
  },
  {
    "path": "src/ciphers/rot13.rs",
    "chars": 686,
    "preview": "pub fn rot13(text: &str) -> String {\n    let to_enc = text.to_uppercase();\n    to_enc\n        .chars()\n        .map(|c| "
  },
  {
    "path": "src/ciphers/rsa_cipher.rs",
    "chars": 10602,
    "preview": "//! RSA Cipher Implementation\n//!\n//! This module provides a basic implementation of the RSA (Rivest-Shamir-Adleman) enc"
  },
  {
    "path": "src/ciphers/salsa.rs",
    "chars": 4728,
    "preview": "macro_rules! quarter_round {\n    ($v1:expr,$v2:expr,$v3:expr,$v4:expr) => {\n        $v2 ^= ($v1.wrapping_add($v4).rotate"
  },
  {
    "path": "src/ciphers/sha256.rs",
    "chars": 11528,
    "preview": "/*!\n * SHA-2 256 bit implementation\n * This implementation is based on RFC6234\n * Keep in mind that the amount of data ("
  },
  {
    "path": "src/ciphers/sha3.rs",
    "chars": 22055,
    "preview": "/// Size of the state array in bits\nconst B: usize = 1600;\n\nconst W: usize = B / 25;\nconst L: usize = W.ilog2() as usize"
  },
  {
    "path": "src/ciphers/tea.rs",
    "chars": 3764,
    "preview": "use std::num::Wrapping as W;\n\nstruct TeaContext {\n    key0: u64,\n    key1: u64,\n}\n\nimpl TeaContext {\n    pub fn new(key:"
  },
  {
    "path": "src/ciphers/theoretical_rot13.rs",
    "chars": 1006,
    "preview": "// in theory rot-13 only affects the lowercase characters in a cipher\npub fn theoretical_rot13(text: &str) -> String {\n "
  },
  {
    "path": "src/ciphers/transposition.rs",
    "chars": 8807,
    "preview": "//! Transposition Cipher\n//!\n//! The Transposition Cipher is a method of encryption by which a message is shifted\n//! ac"
  },
  {
    "path": "src/ciphers/trifid.rs",
    "chars": 9738,
    "preview": "//! The Trifid cipher uses a table to fractionate each plaintext letter into a trigram,\n//! mixes the constituents of th"
  },
  {
    "path": "src/ciphers/vernam.rs",
    "chars": 6726,
    "preview": "//! Vernam Cipher\n//!\n//! The Vernam cipher is a symmetric stream cipher where plaintext is combined\n//! with a random o"
  },
  {
    "path": "src/ciphers/vigenere.rs",
    "chars": 2277,
    "preview": "//! Vigenère Cipher\n//!\n//! # Algorithm\n//!\n//! Rotate each ascii character by the offset of the corresponding key chara"
  },
  {
    "path": "src/ciphers/xor.rs",
    "chars": 1461,
    "preview": "pub fn xor_bytes(text: &[u8], key: u8) -> Vec<u8> {\n    text.iter().map(|c| c ^ key).collect()\n}\n\npub fn xor(text: &str,"
  },
  {
    "path": "src/compression/burrows_wheeler_transform.rs",
    "chars": 8196,
    "preview": "//! Burrows-Wheeler Transform\n//!\n//! The Burrows-Wheeler transform (BWT, also called block-sorting compression)\n//! rea"
  },
  {
    "path": "src/compression/huffman_encoding.rs",
    "chars": 16282,
    "preview": "//! Huffman Encoding implementation\n//!\n//! Huffman coding is a lossless data compression algorithm that assigns variabl"
  },
  {
    "path": "src/compression/lz77.rs",
    "chars": 13195,
    "preview": "//! LZ77 Compression Algorithm\n//!\n//! LZ77 is a lossless data compression algorithm published by Abraham Lempel and Jac"
  },
  {
    "path": "src/compression/mod.rs",
    "chars": 466,
    "preview": "mod burrows_wheeler_transform;\nmod huffman_encoding;\nmod lz77;\nmod move_to_front;\nmod run_length_encoding;\n\npub use self"
  },
  {
    "path": "src/compression/move_to_front.rs",
    "chars": 1537,
    "preview": "// https://en.wikipedia.org/wiki/Move-to-front_transform\n\nfn blank_char_table() -> Vec<char> {\n    (0..=255).map(|ch| ch"
  },
  {
    "path": "src/compression/run_length_encoding.rs",
    "chars": 1829,
    "preview": "// https://en.wikipedia.org/wiki/Run-length_encoding\n\npub fn run_length_encode(text: &str) -> Vec<(char, i32)> {\n    let"
  },
  {
    "path": "src/conversions/binary_to_decimal.rs",
    "chars": 2974,
    "preview": "use num_traits::CheckedAdd;\n\npub fn binary_to_decimal(binary: &str) -> Option<u128> {\n    if binary.len() > 128 {\n      "
  },
  {
    "path": "src/conversions/binary_to_hexadecimal.rs",
    "chars": 2576,
    "preview": "// Author : cyrixninja\n// Binary to Hex Converter : Converts Binary to Hexadecimal\n// Wikipedia References  : 1. https:/"
  },
  {
    "path": "src/conversions/binary_to_octal.rs",
    "chars": 1736,
    "preview": "// Author: NithinU2802\n// Binary to Octal Converter: Converts Binary to Octal\n// Wikipedia References:\n// 1. https://en."
  },
  {
    "path": "src/conversions/decimal_to_binary.rs",
    "chars": 562,
    "preview": "pub fn decimal_to_binary(base_num: u64) -> String {\n    let mut num = base_num;\n    let mut binary_num = String::new();\n"
  },
  {
    "path": "src/conversions/decimal_to_hexadecimal.rs",
    "chars": 1179,
    "preview": "pub fn decimal_to_hexadecimal(base_num: u64) -> String {\n    let mut num = base_num;\n    let mut hexadecimal_num = Strin"
  },
  {
    "path": "src/conversions/decimal_to_octal.rs",
    "chars": 945,
    "preview": "// Author: NithinU2802\n// Decimal to Octal Converter: Converts Decimal to Octal\n// Wikipedia References:\n// 1. https://e"
  },
  {
    "path": "src/conversions/energy.rs",
    "chars": 18648,
    "preview": "//! Convert between different units of energy\n//!\n//! Supports conversions between 70+ energy units using Joule as an in"
  },
  {
    "path": "src/conversions/hexadecimal_to_binary.rs",
    "chars": 1941,
    "preview": "// Author : cyrixninja\n// Hexadecimal to Binary Converter : Converts Hexadecimal to Binary\n// Wikipedia References  : 1."
  },
  {
    "path": "src/conversions/hexadecimal_to_decimal.rs",
    "chars": 1884,
    "preview": "pub fn hexadecimal_to_decimal(hexadecimal_str: &str) -> Result<u64, &'static str> {\n    if hexadecimal_str.is_empty() {\n"
  },
  {
    "path": "src/conversions/hexadecimal_to_octal.rs",
    "chars": 1787,
    "preview": "// Author: NithinU2802\n// Hexadecimal to Octal Converter: Converts Hexadecimal to Octal\n// Wikipedia References:\n// 1. h"
  },
  {
    "path": "src/conversions/ipv4_conversion.rs",
    "chars": 8425,
    "preview": "/// Module for converting between IPv4 addresses and their decimal representations\n///\n/// This module provides function"
  },
  {
    "path": "src/conversions/length_conversion.rs",
    "chars": 2887,
    "preview": "/// Author : https://github.com/ali77gh\n/// Conversion of length units.\n///\n/// Available Units:\n/// -> Wikipedia refere"
  },
  {
    "path": "src/conversions/mod.rs",
    "chars": 2101,
    "preview": "mod binary_to_decimal;\nmod binary_to_hexadecimal;\nmod binary_to_octal;\nmod decimal_to_binary;\nmod decimal_to_hexadecimal"
  },
  {
    "path": "src/conversions/octal_to_binary.rs",
    "chars": 1473,
    "preview": "// Author : cyrixninja\n// Octal to Binary Converter : Converts Octal to Binary\n// Wikipedia References  : 1. https://en."
  },
  {
    "path": "src/conversions/octal_to_decimal.rs",
    "chars": 1486,
    "preview": "// Author: cyrixninja\n// Octal to Decimal Converter: Converts Octal to Decimal\n// Wikipedia References:\n// 1. https://en"
  },
  {
    "path": "src/conversions/octal_to_hexadecimal.rs",
    "chars": 1554,
    "preview": "// Author: NithinU2802\n// Octal to Hexadecimal Converter: Converts Octal to Hexadecimal\n// Wikipedia References:\n// 1. h"
  },
  {
    "path": "src/conversions/order_of_magnitude_conversion.rs",
    "chars": 19384,
    "preview": "//! Length Unit Conversion\n//!\n//! This module provides conversion between metric length units ranging from\n//! meters t"
  },
  {
    "path": "src/conversions/pressure.rs",
    "chars": 15670,
    "preview": "//! Conversion of pressure units.\n//!\n//! This module provides conversion between various pressure units including:\n//! "
  },
  {
    "path": "src/conversions/rectangular_to_polar.rs",
    "chars": 1541,
    "preview": "//! Conversions between rectangular (Cartesian) and polar coordinate systems.\n//!\n//! This module provides utilities for"
  },
  {
    "path": "src/conversions/rgb_cmyk_conversion.rs",
    "chars": 1660,
    "preview": "/// Author : https://github.com/ali77gh\\\n/// References:\\\n/// RGB:  https://en.wikipedia.org/wiki/RGB_color_model\\\n/// C"
  },
  {
    "path": "src/conversions/rgb_hsv_conversion.rs",
    "chars": 13417,
    "preview": "//! Module for converting between RGB and HSV color representations\n//!\n//! The RGB color model is an additive color mod"
  },
  {
    "path": "src/conversions/roman_numerals.rs",
    "chars": 10931,
    "preview": "//! Roman Numeral Conversion\n//!\n//! This module provides conversion between Roman numerals and integers.\n//!\n//! Roman "
  },
  {
    "path": "src/conversions/speed.rs",
    "chars": 7255,
    "preview": "//! Convert speed units\n//!\n//! References:\n//! - <https://en.wikipedia.org/wiki/Kilometres_per_hour>\n//! - <https://en."
  },
  {
    "path": "src/conversions/temperature.rs",
    "chars": 8309,
    "preview": "//! Convert between different units of temperature\n//!\n//! Supports conversions between 8 temperature scales using Kelvi"
  },
  {
    "path": "src/conversions/time.rs",
    "chars": 4867,
    "preview": "//! # Time Unit Conversion\n//!\n//! A unit of time is any particular time interval, used as a standard way of\n//! measuri"
  },
  {
    "path": "src/conversions/volume.rs",
    "chars": 15718,
    "preview": "//! Convert between different units of volume\n//!\n//! Supports conversions between various volume units using cubic mete"
  },
  {
    "path": "src/conversions/weight.rs",
    "chars": 29885,
    "preview": "//! Conversion of weight units.\n//!\n//! This module provides conversion between various weight units including:\n//! - Me"
  },
  {
    "path": "src/data_structures/README.md",
    "chars": 3461,
    "preview": "### [B-Trees](./b_tree.rs)\n\nB-Trees are version of 2-3 trees, which are self-balancing. They are used to improve Disk re"
  },
  {
    "path": "src/data_structures/avl_tree.rs",
    "chars": 10588,
    "preview": "use std::{\n    cmp::{max, Ordering},\n    iter::FromIterator,\n    mem,\n    ops::Not,\n};\n\n/// An internal node of an `AVLT"
  },
  {
    "path": "src/data_structures/b_tree.rs",
    "chars": 6476,
    "preview": "use std::convert::TryFrom;\nuse std::fmt::Debug;\nuse std::mem;\n\nstruct Node<T> {\n    keys: Vec<T>,\n    children: Vec<Node"
  },
  {
    "path": "src/data_structures/binary_search_tree.rs",
    "chars": 10620,
    "preview": "use std::cmp::Ordering;\nuse std::ops::Deref;\n\n/// This struct implements as Binary Search Tree (BST), which is a\n/// sim"
  },
  {
    "path": "src/data_structures/fenwick_tree.rs",
    "chars": 9609,
    "preview": "use std::ops::{Add, AddAssign, Sub, SubAssign};\n\n/// A Fenwick Tree (also known as a Binary Indexed Tree) that supports "
  },
  {
    "path": "src/data_structures/floyds_algorithm.rs",
    "chars": 2774,
    "preview": "// floyds_algorithm.rs\n// https://github.com/rust-lang/rust/blob/master/library/alloc/src/collections/linked_list.rs#L11"
  },
  {
    "path": "src/data_structures/graph.rs",
    "chars": 6076,
    "preview": "use std::collections::{HashMap, HashSet};\nuse std::fmt;\n\n#[derive(Debug, Clone)]\npub struct NodeNotInGraph;\n\nimpl fmt::D"
  },
  {
    "path": "src/data_structures/hash_table.rs",
    "chars": 3700,
    "preview": "use std::collections::LinkedList;\n\npub struct HashTable<K, V> {\n    elements: Vec<LinkedList<(K, V)>>,\n    count: usize,"
  },
  {
    "path": "src/data_structures/heap.rs",
    "chars": 9600,
    "preview": "//! A generic heap data structure.\n//!\n//! This module provides a `Heap` implementation that can function as either a\n//"
  },
  {
    "path": "src/data_structures/lazy_segment_tree.rs",
    "chars": 11230,
    "preview": "use std::fmt::{Debug, Display};\nuse std::ops::{Add, AddAssign, Range};\n\npub struct LazySegmentTree<T: Debug + Default + "
  },
  {
    "path": "src/data_structures/linked_list.rs",
    "chars": 15370,
    "preview": "use std::fmt::{self, Display, Formatter};\nuse std::marker::PhantomData;\nuse std::ptr::NonNull;\n\npub struct Node<T> {\n   "
  },
  {
    "path": "src/data_structures/mod.rs",
    "chars": 1359,
    "preview": "mod avl_tree;\nmod b_tree;\nmod binary_search_tree;\nmod fenwick_tree;\nmod floyds_algorithm;\npub mod graph;\nmod hash_table;"
  },
  {
    "path": "src/data_structures/probabilistic/bloom_filter.rs",
    "chars": 11538,
    "preview": "use std::collections::hash_map::{DefaultHasher, RandomState};\nuse std::hash::{BuildHasher, Hash, Hasher};\n\n/// A Bloom F"
  },
  {
    "path": "src/data_structures/probabilistic/count_min_sketch.rs",
    "chars": 9917,
    "preview": "use std::collections::hash_map::RandomState;\nuse std::fmt::{Debug, Formatter};\nuse std::hash::{BuildHasher, Hash};\n\n/// "
  },
  {
    "path": "src/data_structures/probabilistic/mod.rs",
    "chars": 48,
    "preview": "pub mod bloom_filter;\npub mod count_min_sketch;\n"
  },
  {
    "path": "src/data_structures/queue.rs",
    "chars": 2380,
    "preview": "//! This module provides a generic `Queue` data structure, implemented using\n//! Rust's `LinkedList` from the standard l"
  },
  {
    "path": "src/data_structures/range_minimum_query.rs",
    "chars": 7112,
    "preview": "//! Range Minimum Query (RMQ) Implementation\n//!\n//! This module provides an efficient implementation of a Range Minimum"
  },
  {
    "path": "src/data_structures/rb_tree.rs",
    "chars": 20418,
    "preview": "use std::boxed::Box;\nuse std::cmp::{Ord, Ordering};\nuse std::iter::Iterator;\nuse std::ptr::null_mut;\n\n#[derive(Copy, Clo"
  },
  {
    "path": "src/data_structures/segment_tree.rs",
    "chars": 7881,
    "preview": "//! A module providing a Segment Tree data structure for efficient range queries\n//! and updates. It supports operations"
  },
  {
    "path": "src/data_structures/segment_tree_recursive.rs",
    "chars": 10216,
    "preview": "use std::fmt::Debug;\nuse std::ops::Range;\n\n/// Custom error types representing possible errors that can occur during ope"
  },
  {
    "path": "src/data_structures/skip_list.rs",
    "chars": 11103,
    "preview": "use rand::random_range;\nuse std::{cmp::Ordering, marker::PhantomData, ptr::null_mut};\n\nstruct Node<K: Ord, V> {\n    key:"
  },
  {
    "path": "src/data_structures/stack_using_singly_linked_list.rs",
    "chars": 7522,
    "preview": "// The public struct can hide the implementation detail\npub struct Stack<T> {\n    head: Link<T>,\n}\n\ntype Link<T> = Optio"
  },
  {
    "path": "src/data_structures/treap.rs",
    "chars": 9633,
    "preview": "use std::{\n    cmp::Ordering,\n    iter::FromIterator,\n    mem,\n    ops::Not,\n    time::{SystemTime, UNIX_EPOCH},\n};\n\n///"
  },
  {
    "path": "src/data_structures/trie.rs",
    "chars": 4962,
    "preview": "//! This module provides a generic implementation of a Trie (prefix tree).\n//! A Trie is a tree-like data structure that"
  },
  {
    "path": "src/data_structures/union_find.rs",
    "chars": 7796,
    "preview": "//! A Union-Find (Disjoint Set) data structure implementation in Rust.\n//!\n//! The Union-Find data structure keeps track"
  },
  {
    "path": "src/data_structures/veb_tree.rs",
    "chars": 10308,
    "preview": "// This struct implements Van Emde Boas tree (VEB tree). It stores integers in range [0, U), where\n// O is any integer t"
  },
  {
    "path": "src/dynamic_programming/catalan_numbers.rs",
    "chars": 3339,
    "preview": "//! Catalan Numbers using Dynamic Programming\n//!\n//! The Catalan numbers are a sequence of positive integers that appea"
  },
  {
    "path": "src/dynamic_programming/coin_change.rs",
    "chars": 4219,
    "preview": "//! This module provides a solution to the coin change problem using dynamic programming.\n//! The `coin_change` function"
  },
  {
    "path": "src/dynamic_programming/egg_dropping.rs",
    "chars": 2860,
    "preview": "//! This module contains the `egg_drop` function, which determines the minimum number of egg droppings\n//! required to f"
  },
  {
    "path": "src/dynamic_programming/fibonacci.rs",
    "chars": 16822,
    "preview": "/// Fibonacci via Dynamic Programming\nuse std::collections::HashMap;\n\n/// fibonacci(n) returns the nth fibonacci number\n"
  },
  {
    "path": "src/dynamic_programming/fractional_knapsack.rs",
    "chars": 2857,
    "preview": "pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values: Vec<f64>) -> f64 {\n    // vector of tuple of we"
  },
  {
    "path": "src/dynamic_programming/integer_partition.rs",
    "chars": 3169,
    "preview": "//! Integer partition using dynamic programming\n//!\n//! The number of partitions of a number n into at least k parts equ"
  },
  {
    "path": "src/dynamic_programming/is_subsequence.rs",
    "chars": 2578,
    "preview": "//! A module for checking if one string is a subsequence of another string.\n//!\n//! A subsequence is formed by deleting "
  },
  {
    "path": "src/dynamic_programming/knapsack.rs",
    "chars": 12426,
    "preview": "//! This module provides functionality to solve the knapsack problem using dynamic programming.\n//! It includes structur"
  },
  {
    "path": "src/dynamic_programming/longest_common_subsequence.rs",
    "chars": 4850,
    "preview": "//! This module implements the Longest Common Subsequence (LCS) algorithm.\n//! The LCS problem is finding the longest su"
  },
  {
    "path": "src/dynamic_programming/longest_common_substring.rs",
    "chars": 2757,
    "preview": "//! This module provides a function to find the length of the longest common substring\n//! between two strings using dyn"
  },
  {
    "path": "src/dynamic_programming/longest_continuous_increasing_subsequence.rs",
    "chars": 3335,
    "preview": "use std::cmp::Ordering;\n\n/// Finds the longest continuous increasing subsequence in a slice.\n///\n/// Given a slice of el"
  },
  {
    "path": "src/dynamic_programming/longest_increasing_subsequence.rs",
    "chars": 3407,
    "preview": "/// Finds the longest increasing subsequence and returns it.\n///\n/// If multiple subsequences with the longest possible "
  },
  {
    "path": "src/dynamic_programming/matrix_chain_multiply.rs",
    "chars": 3300,
    "preview": "//! This module implements a dynamic programming solution to find the minimum\n//! number of multiplications needed to mu"
  },
  {
    "path": "src/dynamic_programming/maximal_square.rs",
    "chars": 1681,
    "preview": "use std::cmp::max;\nuse std::cmp::min;\n\n/// Maximal Square\n///\n/// Given an `m` * `n` binary matrix filled with 0's and 1"
  },
  {
    "path": "src/dynamic_programming/maximum_subarray.rs",
    "chars": 2792,
    "preview": "//! This module provides a function to find the largest sum of the subarray\n//! in a given array of integers using dynam"
  },
  {
    "path": "src/dynamic_programming/minimum_cost_path.rs",
    "chars": 4809,
    "preview": "use std::cmp::min;\n\n/// Represents possible errors that can occur when calculating the minimum cost path in a matrix.\n#["
  },
  {
    "path": "src/dynamic_programming/mod.rs",
    "chars": 2161,
    "preview": "mod catalan_numbers;\nmod coin_change;\nmod egg_dropping;\nmod fibonacci;\nmod fractional_knapsack;\nmod integer_partition;\nm"
  },
  {
    "path": "src/dynamic_programming/optimal_bst.rs",
    "chars": 2853,
    "preview": "// Optimal Binary Search Tree Algorithm in Rust\n// Time Complexity: O(n^3) with prefix sum optimization\n// Space Complex"
  },
  {
    "path": "src/dynamic_programming/palindrome_partitioning.rs",
    "chars": 4137,
    "preview": "/// Finds the minimum cuts needed for a palindrome partitioning of a string\n///\n/// Given a string s, partition s such t"
  },
  {
    "path": "src/dynamic_programming/rod_cutting.rs",
    "chars": 2479,
    "preview": "//! This module provides functions for solving the rod-cutting problem using dynamic programming.\nuse std::cmp::max;\n\n//"
  },
  {
    "path": "src/dynamic_programming/smith_waterman.rs",
    "chars": 13550,
    "preview": "//! This module contains the Smith-Waterman algorithm implementation for local sequence alignment.\n//!\n//! The Smith-Wat"
  },
  {
    "path": "src/dynamic_programming/snail.rs",
    "chars": 3772,
    "preview": "/// ## Spiral Sorting\r\n///\r\n/// Given an n x m array, return the array elements arranged from outermost elements\r\n/// to"
  },
  {
    "path": "src/dynamic_programming/subset_generation.rs",
    "chars": 2808,
    "preview": "// list all subset combinations of n element in given set of r element.\n// This is a recursive function that collects al"
  },
  {
    "path": "src/dynamic_programming/subset_sum.rs",
    "chars": 2992,
    "preview": "//! This module provides a solution to the subset sum problem using dynamic programming.\n//!\n//! # Complexity\n//! - Time"
  },
  {
    "path": "src/dynamic_programming/task_assignment.rs",
    "chars": 4057,
    "preview": "// Task Assignment Problem using Bitmasking and DP in Rust\n// Time Complexity: O(2^M * N) where M is number of people an"
  },
  {
    "path": "src/dynamic_programming/trapped_rainwater.rs",
    "chars": 3642,
    "preview": "//! Module to calculate trapped rainwater in an elevation map.\n\n/// Computes the total volume of trapped rainwater in a "
  },
  {
    "path": "src/dynamic_programming/word_break.rs",
    "chars": 3477,
    "preview": "use crate::data_structures::Trie;\n\n/// Checks if a string can be segmented into a space-separated sequence\n/// of one or"
  },
  {
    "path": "src/financial/depreciation.rs",
    "chars": 23713,
    "preview": "//! # Depreciation\n//!\n//! In accounting, depreciation refers to the decreases in the value of a fixed\n//! asset during "
  },
  {
    "path": "src/financial/equated_monthly_installments.rs",
    "chars": 2961,
    "preview": "//! Calculates the Equated Monthly Installment (EMI) for a loan.\n//!\n//! Formula: A = p * r * (1 + r)^n / ((1 + r)^n - 1"
  },
  {
    "path": "src/financial/exponential_moving_average.rs",
    "chars": 4118,
    "preview": "//! Calculate the exponential moving average (EMA) on the series of stock prices.\n//!\n//! Wikipedia Reference: <https://"
  },
  {
    "path": "src/financial/finance_ratios.rs",
    "chars": 1541,
    "preview": "// Calculating simple ratios like Return on Investment (ROI), Debt to Equity, Gross Profit Margin\n// and Earnings per Sa"
  },
  {
    "path": "src/financial/interest.rs",
    "chars": 7227,
    "preview": "//! Calculates simple, compound, and APR interest on a principal amount.\n//!\n//! Formulas:\n//!   Simple Interest:   I = "
  },
  {
    "path": "src/financial/mod.rs",
    "chars": 939,
    "preview": "mod depreciation;\nmod equated_monthly_installments;\nmod exponential_moving_average;\nmod finance_ratios;\nmod interest;\nmo"
  },
  {
    "path": "src/financial/npv.rs",
    "chars": 1199,
    "preview": "/// Calculates Net Present Value given a vector of cash flows and a discount rate.\n/// cash_flows: Vector of f64 represe"
  },
  {
    "path": "src/financial/npv_sensitivity.rs",
    "chars": 1392,
    "preview": "/// Computes the Net Present Value (NPV) of a cash flow series\n/// at multiple discount rates to show sensitivity.\n///\n/"
  },
  {
    "path": "src/financial/payback.rs",
    "chars": 728,
    "preview": "/// Returns the payback period in years\n/// If investment is not paid back, returns None.\n\npub fn payback(cash_flow: &[f"
  },
  {
    "path": "src/financial/present_value.rs",
    "chars": 2766,
    "preview": "/// In economics and finance, present value (PV), also known as present discounted value,\n/// is the value of an expecte"
  },
  {
    "path": "src/financial/treynor_ratio.rs",
    "chars": 1045,
    "preview": "/// Calculates the Treynor Ratio for a portfolio.\n///\n/// # Inputs\n/// - `portfolio_return`: Portfolio return\n/// - `ris"
  },
  {
    "path": "src/general/convex_hull.rs",
    "chars": 4935,
    "preview": "use std::cmp::Ordering::Equal;\n\nfn sort_by_min_angle(pts: &[(f64, f64)], min: &(f64, f64)) -> Vec<(f64, f64)> {\n    let "
  },
  {
    "path": "src/general/fisher_yates_shuffle.rs",
    "chars": 622,
    "preview": "use std::time::{SystemTime, UNIX_EPOCH};\n\nuse crate::math::PCG32;\n\nconst DEFAULT: u64 = 4294967296;\n\nfn gen_range(range:"
  },
  {
    "path": "src/general/genetic.rs",
    "chars": 17642,
    "preview": "use std::cmp::Ordering;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\n/// The goal is to showcase how Genetic al"
  },
  {
    "path": "src/general/hanoi.rs",
    "chars": 594,
    "preview": "pub fn hanoi(n: i32, from: i32, to: i32, via: i32, moves: &mut Vec<(i32, i32)>) {\n    if n > 0 {\n        hanoi(n - 1, fr"
  },
  {
    "path": "src/general/huffman_encoding.rs",
    "chars": 11746,
    "preview": "use std::{\n    cmp::Ordering,\n    collections::{BTreeMap, BinaryHeap},\n};\n\n#[derive(Clone, Copy, PartialEq, Eq, PartialO"
  },
  {
    "path": "src/general/kadane_algorithm.rs",
    "chars": 2222,
    "preview": "/**\n * @file\n * @brief Find the maximum subarray sum using Kadane's algorithm.(https://en.wikipedia.org/wiki/Maximum_sub"
  },
  {
    "path": "src/general/kmeans.rs",
    "chars": 6656,
    "preview": "// Macro to implement kmeans for both f64 and f32 without writing everything\n// twice or importing the `num` crate\nmacro"
  },
  {
    "path": "src/general/mex.rs",
    "chars": 2253,
    "preview": "use std::collections::BTreeSet;\n\n// Find minimum excluded number from a set of given numbers using a set\n/// Finds the M"
  },
  {
    "path": "src/general/mod.rs",
    "chars": 852,
    "preview": "mod convex_hull;\nmod fisher_yates_shuffle;\nmod genetic;\nmod hanoi;\nmod huffman_encoding;\nmod kadane_algorithm;\nmod kmean"
  },
  {
    "path": "src/general/permutations/heap.rs",
    "chars": 2185,
    "preview": "use std::fmt::Debug;\n\n/// Computes all permutations of an array using Heap's algorithm\n/// Read `recurse_naive` first, s"
  },
  {
    "path": "src/general/permutations/mod.rs",
    "chars": 3070,
    "preview": "mod heap;\nmod naive;\nmod steinhaus_johnson_trotter;\n\npub use self::heap::heap_permute;\npub use self::naive::{permute, pe"
  },
  {
    "path": "src/general/permutations/naive.rs",
    "chars": 4999,
    "preview": "use std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\n/// Here's a basic (naive) implementation for "
  },
  {
    "path": "src/general/permutations/steinhaus_johnson_trotter.rs",
    "chars": 1892,
    "preview": "/// <https://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm>\npub fn steinhaus_johnson_trotter"
  },
  {
    "path": "src/general/subarray_sum_equals_k.rs",
    "chars": 1750,
    "preview": "use std::collections::HashMap;\n\n/// Counts the number of contiguous subarrays that sum to exactly k.\n///\n/// # Parameter"
  },
  {
    "path": "src/general/two_sum.rs",
    "chars": 2096,
    "preview": "use std::collections::HashMap;\n\n/// Given an array of integers nums and an integer target,\n/// return indices of the two"
  },
  {
    "path": "src/geometry/closest_points.rs",
    "chars": 6763,
    "preview": "use crate::geometry::Point;\nuse std::cmp::Ordering;\n\nfn cmp_x(p1: &Point, p2: &Point) -> Ordering {\n    let acmp = f64_c"
  },
  {
    "path": "src/geometry/graham_scan.rs",
    "chars": 6895,
    "preview": "use crate::geometry::Point;\nuse std::cmp::Ordering;\n\nfn point_min(a: &&Point, b: &&Point) -> Ordering {\n    // Find the "
  }
]

// ... and 238 more files (download for full content)

About this extraction

This page contains the full source code of the TheAlgorithms/Rust GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 438 files (1.8 MB), approximately 563.5k tokens, and a symbol index with 3217 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!