id
stringlengths
18
18
chunk_id
stringlengths
16
16
repo
stringclasses
6 values
repo_url
stringclasses
6 values
commit
stringclasses
6 values
license
stringclasses
4 values
path
stringlengths
10
68
kind
stringclasses
1 value
name
stringlengths
5
44
context
stringlengths
10
68
start_line
int32
1
1
end_line
int32
3
1.42k
num_lines
int32
3
1.42k
question
stringlengths
133
1.46k
answer
stringlengths
44
54.5k
model
stringclasses
1 value
3ebdb1af589366b0-0
3ebdb1af589366b0
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/leaky_relu.rs
file
leaky_relu.rs
src/math/leaky_relu.rs
1
47
47
I need a Rust function named `leaky_relu` that computes the Leaky ReLU activation on a vector of `f64` values. It should take a reference to a `Vec<f64>` and an `f64` alpha parameter, and return a new `Vec<f64>` where each element is kept unchanged if it is non-negative, and multiplied by alpha if it is negative. The o...
//! # Leaky ReLU Function //! //! The `leaky_relu` function computes the Leaky Rectified Linear Unit (ReLU) values of a given vector //! of f64 numbers with a specified alpha parameter. //! //! The Leaky ReLU activation function is commonly used in neural networks to introduce a small negative //! slope (controlled by ...
nvidia/nemotron-3.5-lightning-30b-a3b
8fe85a745bb74208-0
8fe85a745bb74208
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/faster_perfect_numbers.rs
file
faster_perfect_numbers.rs
src/math/faster_perfect_numbers.rs
1
40
40
I need a Rust function `generate_perfect_numbers` that takes a `usize` limit and returns a `Vec<usize>` containing all perfect numbers up to that limit. The implementation should use the Lucas-Lehmer primality test logic, specifically finding Mersenne primes and then applying the formula `(2^p - 1) * (2^(p-1))` to prod...
use super::{mersenne_primes::is_mersenne_prime, prime_numbers::prime_numbers}; use std::convert::TryInto; /* Generates a list of perfect numbers till `num` using the Lucas Lehmer test algorithm. url : https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test */ pub fn generate_perfect_numbers(num: usiz...
nvidia/nemotron-3.5-lightning-30b-a3b
9639a219a3e35ef5-0
9639a219a3e35ef5
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/lucas_series.rs
file
lucas_series.rs
src/math/lucas_series.rs
1
60
60
I need a Rust module with two functions to compute the Nth Lucas number: recursive_lucas_number and dynamic_lucas_number. Both take a u32 argument n and return a u32. The recursive version should use pattern matching on the base cases 0 and 1, returning 2 and 1 respectively, and recursively sum the two preceding values...
// Author : cyrixninja // Lucas Series : Function to get the Nth Lucas Number // Wikipedia Reference : https://en.wikipedia.org/wiki/Lucas_number // Other References : https://the-algorithms.com/algorithm/lucas-series?lang=python pub fn recursive_lucas_number(n: u32) -> u32 { match n { 0 => 2, ...
nvidia/nemotron-3.5-lightning-30b-a3b
ea6368d540813474-0
ea6368d540813474
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/mersenne_primes.rs
file
mersenne_primes.rs
src/math/mersenne_primes.rs
1
39
39
Write a Rust function named `is_mersenne_prime` that determines whether a given positive integer `n` is a Mersenne prime. The function should implement the Lucas-Lehmer primality test: initialize `s` to 4, then iterate `n - 2` times, updating `s` to `((s * s) - 2) % (2_usize.pow(n) - 1)` on each iteration. Return `true...
// mersenne prime : https://en.wikipedia.org/wiki/Mersenne_prime pub fn is_mersenne_prime(n: usize) -> bool { if n == 2 { return true; } let mut s = 4; let m = 2_usize.pow(std::convert::TryInto::try_into(n).unwrap()) - 1; for _ in 0..n - 2 { s = ((s * s) - 2) % m; } s == 0 } ...
nvidia/nemotron-3.5-lightning-30b-a3b
4b836a74422c3476-0
4b836a74422c3476
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/pascal_triangle.rs
file
pascal_triangle.rs
src/math/pascal_triangle.rs
1
52
52
I need a Rust function `pascal_triangle` that takes `num_rows: i32` and returns `Vec<Vec<i32>>` representing the first `num_rows` of Pascal's triangle. The implementation should iteratively compute each row using binomial coefficients (multiplying by `i-k` and dividing by `k`), resulting in O(n^2) time and space comple...
/// ## Pascal's triangle problem /// /// pascal_triangle(num_rows) returns the first num_rows of Pascal's triangle.\ /// About Pascal's triangle: <https://en.wikipedia.org/wiki/Pascal%27s_triangle> /// /// # Arguments: /// * `num_rows`: number of rows of triangle /// /// # Complexity /// - time complexity: O(n^2), ...
nvidia/nemotron-3.5-lightning-30b-a3b
ec551567ffe87b50-0
ec551567ffe87b50
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/perfect_cube.rs
file
perfect_cube.rs
src/math/perfect_cube.rs
1
61
61
Write a Rust function named `perfect_cube_binary_search` that takes an `i64` and returns `bool`, checking if the number is a perfect cube using binary search. The function should handle negative inputs by recursively calling itself with the absolute value. It should implement binary search between 0 and the absolute va...
// Check if a number is a perfect cube using binary search. pub fn perfect_cube_binary_search(n: i64) -> bool { if n < 0 { return perfect_cube_binary_search(-n); } // Initialize left and right boundaries for binary search. let mut left = 0; let mut right = n.abs(); // Use the absolute value...
nvidia/nemotron-3.5-lightning-30b-a3b
22aac1c7c3416188-0
22aac1c7c3416188
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/newton_raphson.rs
file
newton_raphson.rs
src/math/newton_raphson.rs
1
27
27
I need a Rust module that implements the Newton-Raphson method for finding successively better approximations to the roots of a real-valued function. Specifically, I need a public function `find_root` that takes four parameters: a function `f` of type `fn(f64) -> f64`, a function `fd` of type `fn(f64) -> f64` represent...
pub fn find_root(f: fn(f64) -> f64, fd: fn(f64) -> f64, guess: f64, iterations: i32) -> f64 { let mut result = guess; for _ in 0..iterations { result = iteration(f, fd, result); } result } pub fn iteration(f: fn(f64) -> f64, fd: fn(f64) -> f64, guess: f64) -> f64 { guess - f(guess) / fd(gue...
nvidia/nemotron-3.5-lightning-30b-a3b
830cdf4a2238e052-0
830cdf4a2238e052
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/prime_check.rs
file
prime_check.rs
src/math/prime_check.rs
1
33
33
Write a Rust function `prime_check` that takes a `usize` and returns `bool`, returning `true` for numbers greater than 1 and less than 4, `false` for numbers less than 2 or even numbers, and for odd candidates testing divisibility by odd integers up to the square root of the input.
pub fn prime_check(num: usize) -> bool { if (num > 1) && (num < 4) { return true; } else if (num < 2) || (num.is_multiple_of(2)) { return false; } let stop: usize = (num as f64).sqrt() as usize + 1; for i in (3..stop).step_by(2) { if num.is_multiple_of(i) { retur...
nvidia/nemotron-3.5-lightning-30b-a3b
bad96fdb9df48ee4-0
bad96fdb9df48ee4
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/gaussian_error_linear_unit.rs
file
gaussian_error_linear_unit.rs
src/math/gaussian_error_linear_unit.rs
1
58
58
I need a Rust function named `gaussian_error_linear_unit` that computes the Gaussian Error Linear Unit (GELU) activation for a vector of `f64` values. The function should accept `&Vec<f64>` and return a `Vec<f64>`, applying the GELU formula `0.5 * (1.0 + tanh(2.0 / sqrt(π) * (x + 0.044715 * x^3)))` to each element. I a...
//! # Gaussian Error Linear Unit (GELU) Function //! //! The `gaussian_error_linear_unit` function computes the Gaussian Error Linear Unit (GELU) values of a given f64 number or a vector of f64 numbers. //! //! GELU is an activation function used in neural networks that introduces a smooth approximation of the rectifie...
nvidia/nemotron-3.5-lightning-30b-a3b
e48992a0b6e4d310-0
e48992a0b6e4d310
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/nthprime.rs
file
nthprime.rs
src/math/nthprime.rs
1
58
58
I need a Rust function `nthprime(nth: u64) -> u64` that returns the nth prime number using a Sieve of Eratosthenes‑inspired algorithm. The function should take a `u64` specifying which prime to retrieve (1‑indexed) and return the prime as `u64`. I also need a helper `get_primes(s: u64) -> Vec<u64>` that generates a sie...
// Generate the nth prime number. // Algorithm is inspired by the optimized version of the Sieve of Eratosthenes. pub fn nthprime(nth: u64) -> u64 { let mut total_prime: u64 = 0; let mut size_factor: u64 = 2; let mut s: u64 = nth * size_factor; let mut primes: Vec<u64> = Vec::new(); let n: u64 = n...
nvidia/nemotron-3.5-lightning-30b-a3b
9d3b61df0e465ef7-0
9d3b61df0e465ef7
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/prime_factors.rs
file
prime_factors.rs
src/math/prime_factors.rs
1
36
36
I need a Rust function named prime_factors that takes a u64 and returns a Vec<u64> containing the prime factors of the input in increasing order, with repetition included. The function should return an empty vector for inputs 0 and 1. It should use trial division starting from 2, and after finding a factor, divide it o...
// Finds the prime factors of a number in increasing order, with repetition. pub fn prime_factors(n: u64) -> Vec<u64> { let mut i = 2; let mut n = n; let mut factors = Vec::new(); while i * i <= n { if n.is_multiple_of(i) { n /= i; factors.push(i); } else { ...
nvidia/nemotron-3.5-lightning-30b-a3b
b109dbf64cbe2cbe-0
b109dbf64cbe2cbe
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/relu.rs
file
relu.rs
src/math/relu.rs
1
34
34
Write a Rust function named `relu` that applies the ReLU activation element-wise to a mutable `Vec<f32>`. The function should take `&mut Vec<f32>`, iterate over the values, set any element less than or equal to zero to `0.0`, and return the same mutable reference. Include a test that creates a vector `[1.0, 0.5, -1.0, ...
//Rust implementation of the ReLU (rectified linear unit) activation function. //The formula for ReLU is quite simple really: (if x>0 -> x, else -> 0) //More information on the concepts of ReLU can be found here: //https://en.wikipedia.org/wiki/Rectifier_(neural_networks) //The function below takes a reference to a mu...
nvidia/nemotron-3.5-lightning-30b-a3b
5033b35d510f4d5b-0
5033b35d510f4d5b
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/sieve_of_eratosthenes.rs
file
sieve_of_eratosthenes.rs
src/math/sieve_of_eratosthenes.rs
1
120
120
I need a Rust module that implements the Sieve of Eratosthenes to find all prime numbers up to a given inclusive upper limit. The module should expose a public function `sieve_of_eratosthenes` that accepts a `usize` parameter and returns a `Vec<usize>` containing all primes less than or equal to that limit. The impleme...
/// Implements the Sieve of Eratosthenes algorithm to find all prime numbers up to a given limit. /// /// # Arguments /// /// * `num` - The upper limit up to which to find prime numbers (inclusive). /// /// # Returns /// /// A vector containing all prime numbers up to the specified limit. pub fn sieve_of_eratosthenes(n...
nvidia/nemotron-3.5-lightning-30b-a3b
6debb3638000a653-0
6debb3638000a653
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/softmax.rs
file
softmax.rs
src/math/softmax.rs
1
56
56
I need a Rust function named `softmax` that takes a `Vec<f32>` and returns a `Vec<f32>` containing the softmax probabilities. The function should exponentiate each element using `std::f32::consts::E`, then divide each value by the sum of all exponentiated elements so the output vector sums to 1. The input vector should...
//! # Softmax Function //! //! The `softmax` function computes the softmax values of a given array of f32 numbers. //! //! The softmax operation is often used in machine learning for converting a vector of real numbers into a //! probability distribution. It exponentiates each element in the input array, and then norma...
nvidia/nemotron-3.5-lightning-30b-a3b
bcf6171dbed36888-0
bcf6171dbed36888
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/prime_numbers.rs
file
prime_numbers.rs
src/math/prime_numbers.rs
1
39
39
Write a Rust function named `prime_numbers` that takes a `usize` argument `max` and returns a `Vec<usize>` containing all prime numbers from 2 up to `max`. The function should use trial division: include 2 if `max >= 2`, then iterate odd numbers from 3 to `max`, and for each candidate test divisibility only by odd divi...
pub fn prime_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); if max >= 2 { result.push(2) } for i in (3..=max).step_by(2) { let stop: usize = (i as f64).sqrt() as usize + 1; let mut status = true; for j in (3..stop).step_by(2) { ...
nvidia/nemotron-3.5-lightning-30b-a3b
265d48d092361974-0
265d48d092361974
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/postfix_evaluation.rs
file
postfix_evaluation.rs
src/math/postfix_evaluation.rs
1
105
105
I need a Rust function that evaluates a postfix (Reverse Polish Notation) expression given as a whitespace-separated string. The function should support the four basic arithmetic operators: addition, subtraction, multiplication, and division. It should return Ok(isize) on success or Err(PostfixError) on failure. Define...
//! This module provides a function to evaluate postfix (Reverse Polish Notation) expressions. //! Postfix notation is a mathematical notation in which every operator follows all of its operands. //! //! The evaluator supports the four basic arithmetic operations: addition, subtraction, multiplication, and division. //...
nvidia/nemotron-3.5-lightning-30b-a3b
481b100056547cc0-0
481b100056547cc0
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/sigmoid.rs
file
sigmoid.rs
src/math/sigmoid.rs
1
34
34
I need a Rust function named sigmoid that takes a mutable reference to a Vec<f32> and applies the sigmoid activation function 1 / (1 + e^(-x)) to each element in place, returning the same mutable reference. The implementation should use std::f32::consts::E for the exponent base. Additionally, include a test module with...
//Rust implementation of the Sigmoid activation function. //The formula for Sigmoid: 1 / (1 + e^(-x)) //More information on the concepts of Sigmoid can be found here: //https://en.wikipedia.org/wiki/Sigmoid_function //The function below takes a reference to a mutable <f32> Vector as an argument //and returns the vecto...
nvidia/nemotron-3.5-lightning-30b-a3b
3d87d76bb1c0f313-0
3d87d76bb1c0f313
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/square_pyramidal_numbers.rs
file
square_pyramidal_numbers.rs
src/math/square_pyramidal_numbers.rs
1
20
20
I need a Rust function that computes the nth square pyramidal number using the closed-form formula n*(n+1)*(2*n+1)/6. The function should accept a u64 argument and return a u64 result. Include a test module that verifies the function returns 0 for n=0, 1 for n=1, 5 for n=2, and 14 for n=3.
// https://en.wikipedia.org/wiki/Square_pyramidal_number // 1² + 2² + ... = ... (total) pub fn square_pyramidal_number(n: u64) -> u64 { n * (n + 1) * (2 * n + 1) / 6 } #[cfg(test)] mod tests { use super::*; #[test] fn test0() { assert_eq!(0, square_pyramidal_number(0)); assert_eq!(1,...
nvidia/nemotron-3.5-lightning-30b-a3b
4c38cb7cae62de13-0
4c38cb7cae62de13
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/sum_of_harmonic_series.rs
file
sum_of_harmonic_series.rs
src/math/sum_of_harmonic_series.rs
1
40
40
I need a Rust function that calculates the sum of the first n terms of a harmonic progression, given the progression's first term, a common difference that relates it to an underlying arithmetic progression, and the number of terms. The function should accept first_term: f64, common_difference: f64, and number_of_terms...
// Author : cyrixninja // Sum of Harmonic Series : Find the sum of n terms in an harmonic progression. The calculation starts with the // first_term and loops adding the common difference of Arithmetic Progression by which // the given Harmonic Progression is ...
nvidia/nemotron-3.5-lightning-30b-a3b
9c9641f56ef436f7-0
9c9641f56ef436f7
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/sum_of_geometric_progression.rs
file
sum_of_geometric_progression.rs
src/math/sum_of_geometric_progression.rs
1
37
37
I need a Rust function named sum_of_geometric_progression that computes the sum of the first n terms of a geometric progression. It should accept first_term: f64, common_ratio: f64, and num_of_terms: i32, and return an f64. The function must handle the special case where the common ratio is exactly 1.0 by returning n *...
// Author : cyrixninja // Find the Sum of Geometric Progression // Wikipedia: https://en.wikipedia.org/wiki/Geometric_progression pub fn sum_of_geometric_progression(first_term: f64, common_ratio: f64, num_of_terms: i32) -> f64 { if common_ratio == 1.0 { // Formula for sum if the common ratio is 1 ...
nvidia/nemotron-3.5-lightning-30b-a3b
d1198e9b491d6d36-0
d1198e9b491d6d36
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/tanh.rs
file
tanh.rs
src/math/tanh.rs
1
34
34
Write a Rust function that takes a mutable reference to a `Vec<f32>` and applies the hyperbolic tangent activation element-wise using the formula `(2/(1+e^(-2x))-1)` with `std::f32::consts::E`, modifying the vector in place and returning it. Include a test asserting the transformation of `[1.0, 0.5, -1.0, 0.0, 0.3]` in...
//Rust implementation of the Tanh (hyperbolic tangent) activation function. //The formula for Tanh: (e^x - e^(-x))/(e^x + e^(-x)) OR (2/(1+e^(-2x))-1 //More information on the concepts of Sigmoid can be found here: //https://en.wikipedia.org/wiki/Hyperbolic_functions //The function below takes a reference to a mutable...
nvidia/nemotron-3.5-lightning-30b-a3b
f65ed8e71135b755-0
f65ed8e71135b755
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/zellers_congruence_algorithm.rs
file
zellers_congruence_algorithm.rs
src/math/zellers_congruence_algorithm.rs
1
54
54
I need a Rust function that implements Zeller's Congruence to find the day of the week from a Gregorian date. It should accept three `i32` arguments: `date` (day of month), `month`, and `year`, plus a boolean `as_string`. If `as_string` is true, return the full day name (e.g., "Friday"); otherwise return the day index ...
// returns the day of the week from the Gregorian Date pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String { let q = date; let (m, y) = if month < 3 { (month + 12, year - 1) } else { (month, year) }; let day: i32 = (q + (26 * (m +...
nvidia/nemotron-3.5-lightning-30b-a3b
128e78eafc51a672-0
128e78eafc51a672
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/sprague_grundy_theorem.rs
file
sprague_grundy_theorem.rs
src/math/sprague_grundy_theorem.rs
1
70
70
I need a Rust function `calculate_grundy_number` that computes the Grundy number for a position in a combinatorial game using the Sprague-Grundy theorem. The function should accept the current position as `i64`, a mutable slice of `i64` for memoization (initialized with -1), and a slice of allowed move sizes as `&[i64]...
/** * Sprague Grundy Theorem for combinatorial games like Nim * * The Sprague Grundy Theorem is a fundamental concept in combinatorial game theory, commonly used to analyze * games like Nim. It calculates the Grundy number (also known as the nimber) for a position in a game. * The Grundy number represents the game...
nvidia/nemotron-3.5-lightning-30b-a3b
594bff6b05761175-0
594bff6b05761175
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/trial_division.rs
file
trial_division.rs
src/math/trial_division.rs
1
59
59
I'm looking for a Rust implementation of a function named `trial_division` that performs prime factorization on a 128-bit integer. The function should take an `i128` as input and return a `Vec<i128>` containing the prime factors in ascending order, with repetition allowed. It must handle negative inputs by internal con...
fn floor(value: f64, scale: u8) -> f64 { let multiplier = 10i64.pow(scale as u32) as f64; (value * multiplier).floor() } fn double_to_int(amount: f64) -> i128 { amount.round() as i128 } pub fn trial_division(mut num: i128) -> Vec<i128> { if num < 0 { return trial_division(-num); } let ...
nvidia/nemotron-3.5-lightning-30b-a3b
c5c9bf83517a02c6-0
c5c9bf83517a02c6
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/navigation/bearing.rs
file
bearing.rs
src/navigation/bearing.rs
1
40
40
I need a Rust function `bearing` that takes four `f64` arguments—`lat1`, `lng1`, `lat2`, `lng2` representing decimal-degree coordinates of a start and end point—and returns the initial compass bearing in degrees from the start to the end, normalized to [0, 360). The implementation should convert degrees to radians, com...
use std::f64::consts::PI; pub fn bearing(lat1: f64, lng1: f64, lat2: f64, lng2: f64) -> f64 { let lat1 = lat1 * PI / 180.0; let lng1 = lng1 * PI / 180.0; let lat2 = lat2 * PI / 180.0; let lng2 = lng2 * PI / 180.0; let delta_longitude = lng2 - lng1; let y = delta_longitude.sin() * lat2.cos();...
nvidia/nemotron-3.5-lightning-30b-a3b
93e2fce9f2edb1ca-0
93e2fce9f2edb1ca
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/navigation/haversine.rs
file
haversine.rs
src/navigation/haversine.rs
1
35
35
I want to write a Rust module that implements a `haversine` function to compute the great-circle distance between two points on Earth. The function should accept four `f64` arguments—`lat1`, `lng1`, `lat2`, `lng2`—representing decimal degrees and return the distance in meters as `f64`. I need to use Earth's mean radius...
use std::f64::consts::PI; const EARTH_RADIUS: f64 = 6371000.00; pub fn haversine(lat1: f64, lng1: f64, lat2: f64, lng2: f64) -> f64 { let delta_dist_lat = (lat2 - lat1) * PI / 180.0; let delta_dist_lng = (lng2 - lng1) * PI / 180.0; let cos1 = lat1 * PI / 180.0; let cos2 = lat2 * PI / 180.0; let ...
nvidia/nemotron-3.5-lightning-30b-a3b
b03c56af8ff2844e-0
b03c56af8ff2844e
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/searching/binary_search.rs
file
binary_search.rs
src/searching/binary_search.rs
1
153
153
I need a Rust module implementing a binary search algorithm that works for both ascending and descending sorted arrays. The function, named `binary_search`, should be generic over `T: Ord`, take a reference to the item and a slice of the array, and return `Option<usize>` — `Some(index)` if found, `None` otherwise. It m...
//! This module provides an implementation of a binary search algorithm that //! works for both ascending and descending ordered arrays. The binary search //! function returns the index of the target element if it is found, or `None` //! if the target is not present in the array. use std::cmp::Ordering; /// Performs ...
nvidia/nemotron-3.5-lightning-30b-a3b
fb5bd3095dcbbe36-0
fb5bd3095dcbbe36
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/number_theory/mod.rs
file
mod.rs
src/number_theory/mod.rs
1
7
7
I need a Rust module file that sets up a number theory module by declaring three submodules—`compute_totient`, `euler_totient`, and `kth_factor`—and re-exporting their publicly defined functions with the same names using `pub use self::...` statements.
mod compute_totient; mod euler_totient; mod kth_factor; pub use self::compute_totient::compute_totient; pub use self::euler_totient::euler_totient; pub use self::kth_factor::kth_factor;
nvidia/nemotron-3.5-lightning-30b-a3b
ce8969a990d46f01-0
ce8969a990d46f01
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/number_theory/euler_totient.rs
file
euler_totient.rs
src/number_theory/euler_totient.rs
1
74
74
I need a Rust function `euler_totient` that computes Euler's totient φ(n) for a given `n` of type `u64`, returning `u64`. The function should use trial division to find all distinct prime factors of `n`: iterate `p` from 2 while `p * p <= num`, and if `num.is_multiple_of(p)`, divide `num` by `p` repeatedly and update `...
pub fn euler_totient(n: u64) -> u64 { let mut result = n; let mut num = n; let mut p = 2; // Find all prime factors and apply formula while p * p <= num { // Check if p is a divisor of n if num.is_multiple_of(p) { // If yes, then it is a prime factor // Appl...
nvidia/nemotron-3.5-lightning-30b-a3b
4d6e7a8fe7094266-0
4d6e7a8fe7094266
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/searching/mod.rs
file
mod.rs
src/searching/mod.rs
1
37
37
I need a Rust module file that organizes and re-exports implementations of several searching and selection algorithms. The file should declare submodules for binary search (iterative and recursive), exponential search, fibonacci search, interpolation search, jump search, kth smallest element using a heap and quickselec...
mod binary_search; mod binary_search_recursive; mod exponential_search; mod fibonacci_search; mod interpolation_search; mod jump_search; mod kth_smallest; mod kth_smallest_heap; mod linear_search; mod moore_voting; mod quick_select; mod saddleback_search; mod ternary_search; mod ternary_search_min_max; mod ternary_sear...
nvidia/nemotron-3.5-lightning-30b-a3b
cff4b1b3cf09124d-0
cff4b1b3cf09124d
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/searching/linear_search.rs
file
linear_search.rs
src/searching/linear_search.rs
1
76
76
I need a Rust function called `linear_search` that performs a linear search on a slice of ordered items. It should take a reference to the item to find and a slice of the same type, where the type implements `Ord`, and return `Option<usize>` with the index of the first match, or `None` if the item is not in the slice. ...
/// Performs a linear search on the given array, returning the index of the first occurrence of the item. /// /// # Arguments /// /// * `item` - A reference to the item to search for in the array. /// * `arr` - A slice of items to search within. /// /// # Returns /// /// * `Some(usize)` - The index of the first occurre...
nvidia/nemotron-3.5-lightning-30b-a3b
f8c2b469a2910533-0
f8c2b469a2910533
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/searching/binary_search_recursive.rs
file
binary_search_recursive.rs
src/searching/binary_search_recursive.rs
1
94
94
I need a recursive binary search function in Rust named `binary_search_rec` that takes a generic item `&T` where `T: Ord`, a sorted slice `&[T]`, and left/right bounds, and returns `Option<usize>`. The function should detect the sort direction by comparing the first and last elements of the slice, then perform recursiv...
use std::cmp::Ordering; /// Recursively performs a binary search for a specified item within a sorted array. /// /// This function can handle both ascending and descending ordered arrays. It /// takes a reference to the item to search for and a slice of the array. If /// the item is found, it returns the index of the ...
nvidia/nemotron-3.5-lightning-30b-a3b
2cf11e022a071c73-0
2cf11e022a071c73
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/binary_insertion_sort.rs
file
binary_insertion_sort.rs
src/sorting/binary_insertion_sort.rs
1
51
51
I need a Rust function that implements binary insertion sort on a mutable slice. The function should accept a slice of types that implement Ord and Clone, use a helper binary search to find the correct insertion position for each element starting from index 1, shift the intervening elements right using rotate_right, an...
fn _binary_search<T: Ord>(arr: &[T], target: &T) -> usize { let mut low = 0; let mut high = arr.len(); while low < high { let mid = low + (high - low) / 2; if arr[mid] < *target { low = mid + 1; } else { high = mid; } } low } pub fn binary_...
nvidia/nemotron-3.5-lightning-30b-a3b
666fd6694505ceee-0
666fd6694505ceee
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/searching/quick_select.rs
file
quick_select.rs
src/searching/quick_select.rs
1
44
44
I need a Rust function `quick_select` that implements the quickselect algorithm to find the element at a given index in a mutable slice of `i32`s, as if the slice were sorted. The function should take `&mut [i32]`, `left: usize`, `right: usize`, and `index: usize`, and return `i32`. A helper `partition` should rearrang...
// https://en.wikipedia.org/wiki/Quickselect fn partition(list: &mut [i32], left: usize, right: usize, pivot_index: usize) -> usize { let pivot_value = list[pivot_index]; list.swap(pivot_index, right); // Move pivot to end let mut store_index = left; for i in left..right { if list[i] < pivot_va...
nvidia/nemotron-3.5-lightning-30b-a3b
2a0eea28ec438f6e-0
2a0eea28ec438f6e
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/math/perfect_numbers.rs
file
perfect_numbers.rs
src/math/perfect_numbers.rs
1
47
47
I need a Rust implementation of a function `is_perfect_number` that takes a `usize` and returns `bool`, indicating whether the number is perfect (equal to the sum of its proper divisors). I also need a function `perfect_numbers` that takes a `usize` limit and returns a `Vec<usize>` of all perfect numbers up to that lim...
pub fn is_perfect_number(num: usize) -> bool { let mut sum = 0; for i in 1..num - 1 { if num.is_multiple_of(i) { sum += i; } } num == sum } pub fn perfect_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); // It is not known if there are ...
nvidia/nemotron-3.5-lightning-30b-a3b
db67d8f03c059414-0
db67d8f03c059414
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/navigation/mod.rs
file
mod.rs
src/navigation/mod.rs
1
8
8
I need a Rust module file that declares three sub-modules named bearing, haversine, and rhumbline, and re-exports the bearing function from the bearing module, the haversine function from the haversine module, and rhumb_bearing, rhumb_destination, and rhumb_dist from the rhumbline module at the top level.
mod bearing; mod haversine; mod rhumbline; pub use self::bearing::bearing; pub use self::haversine::haversine; pub use self::rhumbline::rhumb_bearing; pub use self::rhumbline::rhumb_destination; pub use self::rhumbline::rhumb_dist;
nvidia/nemotron-3.5-lightning-30b-a3b
9d27c37815515c31-0
9d27c37815515c31
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/cycle_sort.rs
file
cycle_sort.rs
src/sorting/cycle_sort.rs
1
60
60
I need a Rust function `cycle_sort` that takes a mutable slice of `i32` and sorts it in-place using the cycle sort algorithm, which minimizes the number of element writes. The function should iterate through the array, and for each starting position compute the correct position of the current element by counting how ma...
// sorts with the minimum number of rewrites. Runs through all values in the array, placing them in their correct spots. O(n^2). pub fn cycle_sort(arr: &mut [i32]) { for cycle_start in 0..arr.len() { let mut item = arr[cycle_start]; let mut pos = cycle_start; for i in arr.iter().skip(cycle_...
nvidia/nemotron-3.5-lightning-30b-a3b
01469d07ab830e9d-0
01469d07ab830e9d
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/intro_sort.rs
file
intro_sort.rs
src/sorting/intro_sort.rs
1
107
107
I need a Rust function `intro_sort` that sorts a mutable slice `&mut [T]` where `T: Ord` using Intro Sort (Introspective Sort). The implementation must be a hybrid of Insertion Sort, Quick Sort, and Heap Sort: sort subarrays of length 16 or fewer with Insertion Sort; use Quick Sort with a pivot chosen as the middle ele...
// Intro Sort (Also known as Introspective Sort) // Introspective Sort is hybrid sort (Quick Sort + Heap Sort + Insertion Sort) // https://en.wikipedia.org/wiki/Introsort fn insertion_sort<T: Ord>(arr: &mut [T]) { for i in 1..arr.len() { let mut j = i; while j > 0 && arr[j] < arr[j - 1] { ...
nvidia/nemotron-3.5-lightning-30b-a3b
565b10394181e66d-0
565b10394181e66d
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/pigeonhole_sort.rs
file
pigeonhole_sort.rs
src/sorting/pigeonhole_sort.rs
1
38
38
Write a Rust function named `pigeonhole_sort` that sorts a mutable slice of `i32` in ascending order in place using the pigeonhole sorting algorithm. The function should take `&mut [i32]`, find the minimum and maximum values to compute the range of values, create hole structures to store each element's value and its oc...
// From Wikipedia: Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements (n) and the length of the range of possible key values (N) are approximately the same. It requires O(n + N) time. pub fn pigeonhole_sort(array: &mut [i32]) { if let (Some(min), S...
nvidia/nemotron-3.5-lightning-30b-a3b
153ddd6615147f48-0
153ddd6615147f48
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/heap_sort.rs
file
heap_sort.rs
src/sorting/heap_sort.rs
1
114
114
I need a Rust module implementing heap sort for a mutable slice of any type `T: Ord`. The module should provide a `build_heap` function that builds either a max heap or min heap based on a boolean flag, a `heapify` function that fixes a heap violation at a given index using a comparator determined by that flag, and a `...
//! This module provides functions for heap sort algorithm. use std::cmp::Ordering; /// Builds a heap from the provided array. /// /// This function builds either a max heap or a min heap based on the `is_max_heap` parameter. /// /// # Arguments /// /// * `arr` - A mutable reference to the array to be sorted. /// * `...
nvidia/nemotron-3.5-lightning-30b-a3b
9d9caa345a15eee3-0
9d9caa345a15eee3
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/exchange_sort.rs
file
exchange_sort.rs
src/sorting/exchange_sort.rs
1
38
38
I need a Rust function that performs an exchange sort on a mutable slice of integers. Specifically, I am looking for a function named `exchange_sort` that takes a `&mut [i32]` argument and sorts the slice in ascending order in place. The algorithm should use nested loops: the outer loop iterates over each position in t...
// sorts through swapping the first value until it is at the right position, and repeating for all the following. pub fn exchange_sort(arr: &mut [i32]) { let length = arr.len(); for number1 in 0..length { for number2 in (number1 + 1)..length { if arr[number2] < arr[number1] { ...
nvidia/nemotron-3.5-lightning-30b-a3b
80e7f7787c94ef21-0
80e7f7787c94ef21
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/anagram.rs
file
anagram.rs
src/string/anagram.rs
1
111
111
I need a Rust function `check_anagram(s: &str, t: &str) -> Result<bool, AnagramError>` that determines if two strings are anagrams, ignoring spaces and case sensitivity. The implementation must define a custom error type `AnagramError` with a variant `NonAlphabeticCharacter` returned when either string contains non-alp...
use std::collections::HashMap; /// Custom error type representing an invalid character found in the input. #[derive(Debug, PartialEq)] pub enum AnagramError { NonAlphabeticCharacter, } /// Checks if two strings are anagrams, ignoring spaces and case sensitivity. /// /// # Arguments /// /// * `s` - First input str...
nvidia/nemotron-3.5-lightning-30b-a3b
ecfc868a0ee7a5ee-0
ecfc868a0ee7a5ee
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/boyer_moore_search.rs
file
boyer_moore_search.rs
src/string/boyer_moore_search.rs
1
161
161
I need a Rust implementation of the Boyer-Moore string search algorithm that finds all occurrences of a pattern within a text string using the bad character heuristic. The module should export a function `boyer_moore_search(text: &str, pat: &str) -> Vec<usize>` returning starting indices where the pattern is found in t...
//! This module implements the Boyer-Moore string search algorithm, an efficient method //! for finding all occurrences of a pattern within a given text. The algorithm skips //! sections of the text by leveraging two key rules: the bad character rule and the //! good suffix rule (only the bad character rule is implemen...
nvidia/nemotron-3.5-lightning-30b-a3b
79bfc6c74ebf4f9f-0
79bfc6c74ebf4f9f
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/isogram.rs
file
isogram.rs
src/string/isogram.rs
1
104
104
I need a Rust module that checks whether a string is an isogram, meaning no alphabetic character appears more than once, ignoring case and spaces. The module should define a custom error enum IsogramError with a NonAlphabeticCharacter variant, a function count_letters that takes &str and returns Result<HashMap<char, us...
//! This module provides functionality to check if a given string is an isogram. //! An isogram is a word or phrase in which no letter occurs more than once. use std::collections::HashMap; /// Enum representing possible errors that can occur while checking for isograms. #[derive(Debug, PartialEq, Eq)] pub enum Isogra...
nvidia/nemotron-3.5-lightning-30b-a3b
77d0ed99008ca9fc-0
77d0ed99008ca9fc
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/hamming_distance.rs
file
hamming_distance.rs
src/string/hamming_distance.rs
1
57
57
I need a Rust function to compute the Hamming distance between two strings. The function should be called `hamming_distance`, take two `&str` parameters, and return `Result<usize, HammingDistanceError>`. I also need a custom error enum `HammingDistanceError` with a variant `InputStringsHaveDifferentLength` that gets re...
/// Error type for Hamming distance calculation. #[derive(Debug, PartialEq)] pub enum HammingDistanceError { InputStringsHaveDifferentLength, } /// Calculates the Hamming distance between two strings. /// /// The Hamming distance is defined as the number of positions at which the corresponding characters of the tw...
nvidia/nemotron-3.5-lightning-30b-a3b
0de86a1804b5f56f-0
0de86a1804b5f56f
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/duval_algorithm.rs
file
duval_algorithm.rs
src/string/duval_algorithm.rs
1
97
97
Write a Rust function `duval_algorithm` that factorizes a string into its Lyndon words using Duval's algorithm. The function should accept a `&str` and return `Vec<String>`, where each string is a Lyndon word from the factorization. Implement a helper `factorize_duval` that takes `&[char]` and performs the linear-time ...
//! Implementation of Duval's Algorithm to compute the standard factorization of a string //! into Lyndon words. A Lyndon word is defined as a string that is strictly smaller //! (lexicographically) than any of its nontrivial suffixes. This implementation operates //! in linear time and space. /// Performs Duval's alg...
nvidia/nemotron-3.5-lightning-30b-a3b
fc69edc285183f14-0
fc69edc285183f14
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/sort_utils.rs
file
sort_utils.rs
src/sorting/sort_utils.rs
1
65
65
I need a Rust source file with functions to generate different types of test vectors for sorting algorithm benchmarks: completely random, already sorted, reverse sorted, nearly sorted with a controlled number of swaps, and with a specified number of repeated values. Also include a helper function that measures and prin...
#[cfg(test)] use rand::RngExt; #[cfg(test)] use std::time::Instant; #[cfg(test)] pub fn generate_random_vec(n: u32, range_l: i32, range_r: i32) -> Vec<i32> { let mut arr = Vec::<i32>::with_capacity(n as usize); let mut rng = rand::rng(); let mut count = n; while count > 0 { arr.push(rng.random...
nvidia/nemotron-3.5-lightning-30b-a3b
f026c78b020cadd5-0
f026c78b020cadd5
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/isomorphism.rs
file
isomorphism.rs
src/string/isomorphism.rs
1
83
83
I need a Rust function `is_isomorphic` that checks whether two strings are isomorphic by mapping characters between them bijectively using HashMaps. It should accept two `&str` slices, return `bool`, handle Unicode characters, immediately return `false` if the strings have different lengths, and correctly determine iso...
//! This module provides functionality to determine whether two strings are isomorphic. //! //! Two strings are considered isomorphic if the characters in one string can be replaced //! by some mapping relation to obtain the other string. use std::collections::HashMap; /// Determines whether two strings are isomorphic...
nvidia/nemotron-3.5-lightning-30b-a3b
94640cd0bfb5b3e8-0
94640cd0bfb5b3e8
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/jaro_winkler_distance.rs
file
jaro_winkler_distance.rs
src/string/jaro_winkler_distance.rs
1
84
84
I need a Rust function `jaro_winkler_distance` that computes the Jaro–Winkler similarity between two strings. It should accept two `&str` parameters and return an `f64`. The function must return `0.0` if either input is empty, compute matched characters within a window of `min(len1, len2) / 2`, count transpositions bet...
// In computer science and statistics, // the Jaro–Winkler distance is a string metric measuring an edit distance // between two sequences. // It is a variant proposed in 1990 by William E. Winkler // of the Jaro distance metric (1989, Matthew A. Jaro). pub fn jaro_winkler_distance(str1: &str, str2: &str) -> f64 { ...
nvidia/nemotron-3.5-lightning-30b-a3b
8b3f4a61590a8386-0
8b3f4a61590a8386
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/knuth_morris_pratt.rs
file
knuth_morris_pratt.rs
src/string/knuth_morris_pratt.rs
1
146
146
Write a Rust function that implements the Knuth-Morris-Pratt string matching algorithm to find all occurrences of a pattern within a text string. The function should accept two string slices (`string` and `pattern`) and return a `Vec<usize>` containing the starting indices of each match. It must handle edge cases such ...
//! Knuth-Morris-Pratt string matching algorithm implementation in Rust. //! //! This module contains the implementation of the KMP algorithm, which is used for finding //! occurrences of a pattern string within a text string efficiently. The algorithm preprocesses //! the pattern to create a partial match table, which...
nvidia/nemotron-3.5-lightning-30b-a3b
3286aec0cbbe83a3-0
3286aec0cbbe83a3
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/manacher.rs
file
manacher.rs
src/string/manacher.rs
1
90
90
I need a Rust function `manacher` that takes a `String` and returns the longest palindromic substring using Manacher's algorithm. The function should transform the input string by inserting a `'#'` character between each original character and at both ends, enabling uniform detection of both odd- and even-length palind...
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
nvidia/nemotron-3.5-lightning-30b-a3b
145aed383f2e894f-0
145aed383f2e894f
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/levenshtein_distance.rs
file
levenshtein_distance.rs
src/string/levenshtein_distance.rs
1
164
164
Write a Rust module that calculates the Levenshtein distance between two strings. Implement `naive_levenshtein_distance` and `optimized_levenshtein_distance`, both taking `&str` inputs and returning `usize`. Include a private helper `_min3` that returns the minimum of three ordered values. The module should have a `#[c...
//! Provides functions to calculate the Levenshtein distance between two strings. //! //! The Levenshtein distance is a measure of the similarity between two strings by calculating the minimum number of single-character //! edits (insertions, deletions, or substitutions) required to change one string into the other. u...
nvidia/nemotron-3.5-lightning-30b-a3b
764096bc36f00649-0
764096bc36f00649
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/lipogram.rs
file
lipogram.rs
src/string/lipogram.rs
1
112
112
I need a Rust function `is_lipogram` that determines whether a given string is a lipogram relative to a set of expected missing lowercase alphabetic characters. It accepts a string slice and a reference to a `HashSet<char>` of missing characters. The function must first validate that all characters in the missing set a...
use std::collections::HashSet; /// Represents possible errors that can occur when checking for lipograms. #[derive(Debug, PartialEq, Eq)] pub enum LipogramError { /// Indicates that a non-alphabetic character was found in the input. NonAlphabeticCharacter, /// Indicates that a missing character is not in l...
nvidia/nemotron-3.5-lightning-30b-a3b
559a75c66eba9607-0
559a75c66eba9607
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/palindrome.rs
file
palindrome.rs
src/string/palindrome.rs
1
74
74
I need a Rust function `is_palindrome` that takes a string slice `&str` and returns `bool`, checking whether the string reads the same backward as forward while ignoring all non-alphanumeric characters and performing case-insensitive comparison. The implementation should filter the input characters using `is_alphanumer...
//! A module for checking if a given string is a palindrome. /// Checks if the given string is a palindrome. /// /// A palindrome is a sequence that reads the same backward as forward. /// This function ignores non-alphanumeric characters and is case-insensitive. /// /// # Arguments /// /// * `s` - A string slice that...
nvidia/nemotron-3.5-lightning-30b-a3b
5e9a9ec43af1cb4f-0
5e9a9ec43af1cb4f
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/reverse.rs
file
reverse.rs
src/string/reverse.rs
1
40
40
I need a Rust function named `reverse` that accepts a string slice (`&str`) and returns a new `String` with the characters in reverse order. The implementation should properly handle Unicode characters, preserve any leading or trailing whitespace, and work with mixed content including letters, digits, and punctuation. ...
/// Reverses the given string. /// /// # Arguments /// /// * `text` - A string slice that holds the string to be reversed. /// /// # Returns /// /// * A new `String` that is the reverse of the input string. pub fn reverse(text: &str) -> String { text.chars().rev().collect() } #[cfg(test)] mod tests { use super...
nvidia/nemotron-3.5-lightning-30b-a3b
4b335e0168a1dbb7-0
4b335e0168a1dbb7
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/rabin_karp.rs
file
rabin_karp.rs
src/string/rabin_karp.rs
1
123
123
I need a Rust module that implements the Rabin-Karp string-searching algorithm using a rolling hash with a modulo of 101 and radix of 256. Please define a public function `rabin_karp(text: &str, pattern: &str) -> Vec<usize>` that returns all starting indices where `pattern` appears in `text`. Include two private helper...
//! This module implements the Rabin-Karp string searching algorithm. //! It uses a rolling hash technique to find all occurrences of a pattern //! within a target string efficiently. const MOD: usize = 101; const RADIX: usize = 256; /// Finds all starting indices where the `pattern` appears in the `text`. /// /// # ...
nvidia/nemotron-3.5-lightning-30b-a3b
943d5bd3c5b5bf95-0
943d5bd3c5b5bf95
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/pangram.rs
file
pangram.rs
src/string/pangram.rs
1
92
92
I need a Rust module that checks if a given string is a pangram and classifies it into three categories: NotPangram, Pangram, or PerfectPangram (where every letter appears exactly once). The solution should define a `PangramStatus` enum with those three variants, include a function that takes a `&str`, normalize the in...
//! This module provides functionality to check if a given string is a pangram. //! //! A pangram is a sentence that contains every letter of the alphabet at least once. //! This module can distinguish between a non-pangram, a regular pangram, and a //! perfect pangram, where each letter appears exactly once. use std:...
nvidia/nemotron-3.5-lightning-30b-a3b
1da4b66af3c07273-0
1da4b66af3c07273
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/sorting/mod.rs
file
mod.rs
src/sorting/mod.rs
1
131
131
I need a Rust module that publicly re-exports sorting algorithm functions from separate modules, including bead_sort, binary_insertion_sort, bingo_sort, bitonic_sort, bogo_sort, bubble_sort, bucket_sort, cocktail_shaker_sort, comb_sort, counting_sort, generic_counting_sort, cycle_sort, dutch_national_flag_sort, exchang...
mod bead_sort; mod binary_insertion_sort; mod bingo_sort; mod bitonic_sort; mod bogo_sort; mod bubble_sort; mod bucket_sort; mod cocktail_shaker_sort; mod comb_sort; mod counting_sort; mod cycle_sort; mod dutch_national_flag_sort; mod exchange_sort; mod gnome_sort; mod heap_sort; mod insertion_sort; mod intro_sort; mod...
nvidia/nemotron-3.5-lightning-30b-a3b
84a7cee87bb2931d-0
84a7cee87bb2931d
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/suffix_array.rs
file
suffix_array.rs
src/string/suffix_array.rs
1
95
95
I need a Rust function that computes the suffix array of a given lowercase string. The function should accept a string slice and return a `Vec<usize>` containing the starting positions of all suffixes sorted in lexicographic order. The implementation should use a ranking approach where each suffix is initially ranked b...
// In computer science, a suffix array is a sorted array of all suffixes of a string. // It is a data structure used in, among others, full-text indices, data-compression algorithms, // and the field of bibliometrics. Source: https://en.wikipedia.org/wiki/Suffix_array use std::cmp::Ordering; #[derive(Clone)] struct S...
nvidia/nemotron-3.5-lightning-30b-a3b
b24f1c8ec590efc4-0
b24f1c8ec590efc4
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/run_length_encoding.rs
file
run_length_encoding.rs
src/string/run_length_encoding.rs
1
78
78
I need a Rust source file with two public functions: `run_length_encoding` and `run_length_decoding`. The function `run_length_encoding` takes a `&str` and returns a `String` that represents the run-length encoding of the input, where consecutive identical characters are replaced by the count of repetitions followed by...
pub fn run_length_encoding(target: &str) -> String { if target.trim().is_empty() { return "".to_string(); } let mut count: i32 = 0; let mut base_character: String = "".to_string(); let mut encoded_target = String::new(); for c in target.chars() { if base_character == *"" { ...
nvidia/nemotron-3.5-lightning-30b-a3b
eb9676b3b41c8d5d-0
eb9676b3b41c8d5d
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/shortest_palindrome.rs
file
shortest_palindrome.rs
src/string/shortest_palindrome.rs
1
119
119
Write a Rust function `shortest_palindrome` that takes a string slice and returns the shortest palindrome formed by adding characters to the left, using a KMP-style prefix/suffix matching approach to find the longest palindromic prefix. Include helper functions `compute_suffix` and `compute_prefix_match` with the same ...
//! This module provides functions for finding the shortest palindrome //! that can be formed by adding characters to the left of a given string. //! References //! //! - [KMP](https://www.scaler.com/topics/data-structures/kmp-algorithm/) //! - [Prefix Functions and KPM](https://oi-wiki.org/string/kmp/) /// Finds the ...
nvidia/nemotron-3.5-lightning-30b-a3b
ef832e8dd02619f7-0
ef832e8dd02619f7
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/autocomplete_using_trie.rs
file
autocomplete_using_trie.rs
src/string/autocomplete_using_trie.rs
1
125
125
I need a Rust module that implements a prefix-based autocomplete feature using a trie data structure. The module should support inserting a list of words and then finding all words that start with a given prefix. The trie should use a hash map to store child nodes, with a sentinel character marking the end of a word. P...
/* It autocomplete by prefix using added words. word List => ["apple", "orange", "oregano"] prefix => "or" matches => ["orange", "oregano"] */ use std::collections::HashMap; const END: char = '#'; #[derive(Debug)] struct Trie(HashMap<char, Box<Trie>>); impl Trie { fn new() -> Self { Tri...
nvidia/nemotron-3.5-lightning-30b-a3b
6cfac6d1dababd91-0
6cfac6d1dababd91
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust
fed66cb0c74c4a939ec5163648458a8c2b46fd4c
MIT
src/string/suffix_tree.rs
file
suffix_tree.rs
src/string/suffix_tree.rs
1
152
152
I need a Rust implementation of a suffix tree data structure. The code should define a `Node` struct with a `sub` field of type `String` representing a substring and a `ch` field of type `Vec<usize>` representing child node indices. It should also define a `SuffixTree` struct with a `nodes` field of type `Vec<Node>`. T...
// In computer science, a suffix tree (also called PAT tree or, in an earlier form, position tree) // is a compressed trie containing all the suffixes of the given text as their keys and positions // in the text as their values. Suffix trees allow particularly fast implementations of many // important string operations...
nvidia/nemotron-3.5-lightning-30b-a3b
525050140e7d1a9f-0
525050140e7d1a9f
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/api.rs
file
api.rs
src/api.rs
1
14
14
I need a function that fetches provider data from the models.dev API and returns a typed map of providers. The function should make an HTTP GET request to `https://models.dev/api.json`, parse the response as JSON into a `ProvidersMap` type, and use `anyhow` for error reporting with contextual messages on failure. The f...
use anyhow::{Context, Result}; use crate::data::ProvidersMap; const API_URL: &str = "https://models.dev/api.json"; pub fn fetch_providers() -> Result<ProvidersMap> { let response = reqwest::blocking::get(API_URL).context("Failed to fetch data from models.dev API")?; let providers: ProvidersMap = res...
nvidia/nemotron-3.5-lightning-30b-a3b
577d4811e40041c8-0
577d4811e40041c8
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/benchmarks/mod.rs
file
mod.rs
src/benchmarks/mod.rs
1
9
9
I need a Rust module file for a benchmarks module in a fast TUI/CLI application for browsing AI models and coding agents. The file should declare five submodules: fetch, multi, schema, sources, and traits. It should re-export fetch_source from the fetch submodule, ReasoningStatus from the schema module, and the functio...
mod fetch; pub mod multi; pub mod schema; pub mod sources; mod traits; pub use fetch::fetch_source; pub use schema::ReasoningStatus; pub use traits::{apply_model_traits, creator_openness, enrich_from_models_dev, normalize_id};
nvidia/nemotron-3.5-lightning-30b-a3b
33b9efed677e9f25-0
33b9efed677e9f25
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/agents/mod.rs
file
mod.rs
src/agents/mod.rs
1
16
16
I need a Rust module source file that declares eight submodules for an agents component and re-exports their public APIs at the crate root. The submodules are named cache, changelog_parser, data, detect, github, health, helpers, and loader. Five of the submodules should have pub use re-export statements: two of them (c...
pub mod cache; pub mod changelog_parser; pub mod data; pub mod detect; pub mod github; pub mod health; pub mod helpers; pub mod loader; #[allow(unused_imports)] pub use cache::*; pub use data::*; pub use detect::*; #[allow(unused_imports)] pub use github::*; pub use loader::*;
nvidia/nemotron-3.5-lightning-30b-a3b
8a8571593241ba0a-0
8a8571593241ba0a
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/bin/transform/main.rs
file
main.rs
src/bin/transform/main.rs
1
94
94
Create a Rust CLI binary called `transform` that acts as an offline data-pipeline, compiled exclusively with a `pipeline` feature flag to keep the published `models` binary lean. The binary should convert raw benchmark API data dumps into a v2 `SourceFile` JSON schema that the TUI/CLI deserializes. It must use a `#[pat...
//! `transform` — offline data-pipeline binary (feature `pipeline`). //! //! Converts raw upstream benchmark API/data dumps into the v2 `SourceFile` //! schema that the TUI/CLI deserialize. Built only with `--features pipeline` //! so the published `models` binary stays lean. //! //! The crate has no lib target, so the...
nvidia/nemotron-3.5-lightning-30b-a3b
1c9d3de5f2c87fe8-0
1c9d3de5f2c87fe8
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/benchmarks/fetch.rs
file
fetch.rs
src/benchmarks/fetch.rs
1
137
137
I need an async Rust module that provides a `fetch_source` function taking `&SourceDescriptor` and returning `Option<SourceFile>`, which tries a prioritized fallback chain of CDN hosts to fetch per-source benchmark data. Before the chain, the module must check the `MODELS_DATA_BASE_URL` environment variable; if set and...
//! Async HTTP client for fetching per-source benchmark data, with a multi-host //! fallback chain. //! //! `fetch_source` pulls a single source's v2 [`SourceFile`] for the benchmarks //! tab's data-source switcher, trying a chain of hosts so a single jsDelivr edge //! or branch-resolution hiccup can't take the whole t...
nvidia/nemotron-3.5-lightning-30b-a3b
8481c89a11970943-0
8481c89a11970943
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/link.rs
file
link.rs
src/cli/link.rs
1
144
144
I need a Rust module for a CLI tool that manages symlinks to a binary in a target directory. The module should provide a function `run` that takes an optional `Option<PathBuf>` directory, a boolean `remove`, a boolean `status`, and a reference to a `Config` type. When `status` is true, it should display the current sym...
use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; use crate::config::Config; pub fn run(dir: Option<PathBuf>, remove: bool, status: bool, config: &Config) -> Result<()> { let binary = std::env::current_exe().context("could not determine binary path")?; let target_dir = match dir { ...
nvidia/nemotron-3.5-lightning-30b-a3b
a0716cb64483d2b1-0
a0716cb64483d2b1
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/mod.rs
file
mod.rs
src/cli/mod.rs
1
11
11
I need a Rust `mod.rs` file for a CLI module that declares public submodules for agents, agents_ui, benchmarks, link, list, models, picker, search, show, status, and styles. The file should contain `pub mod` statements for each of these components, matching the exact module names and visibility used in the project stru...
pub mod agents; pub mod agents_ui; pub mod benchmarks; pub mod link; pub mod list; pub mod models; pub(crate) mod picker; pub mod search; pub mod show; pub mod status; pub mod styles;
nvidia/nemotron-3.5-lightning-30b-a3b
2bc109247ac90421-0
2bc109247ac90421
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/list.rs
file
list.rs
src/cli/list.rs
1
9
9
I need two thin wrapper functions for a CLI tool that lists AI model providers and models. The first, named providers, should accept a bool json flag and return Result<()>, delegating to super::models::providers(json). The second, named models, should accept an Option<String> for an optional provider filter and a bool ...
use anyhow::Result; pub fn providers(json: bool) -> Result<()> { super::models::providers(json) } pub fn models(provider: Option<String>, json: bool) -> Result<()> { super::models::list(provider.as_deref(), json) }
nvidia/nemotron-3.5-lightning-30b-a3b
59bf52fa8a7106b5-0
59bf52fa8a7106b5
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/search.rs
file
search.rs
src/cli/search.rs
1
5
5
I need a public search function for a CLI tool that accepts a query string and a boolean flag to determine if results should be formatted as JSON, returns anyhow::Result<()>, and delegates the actual search logic to the parent module's models::search function.
use anyhow::Result; pub fn search(query: &str, json: bool) -> Result<()> { super::models::search(query, json) }
nvidia/nemotron-3.5-lightning-30b-a3b
96c9f51f2ec7e37f-0
96c9f51f2ec7e37f
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/show.rs
file
show.rs
src/cli/show.rs
1
5
5
I need a Rust function called `model` that accepts a model identifier string and a boolean flag for JSON output. The function should delegate to `super::models::show` and return a `Result` using the `anyhow` crate for error handling. It should serve as a simple wrapper in a CLI module for browsing AI models.
use anyhow::Result; pub fn model(model_id: &str, json: bool) -> Result<()> { super::models::show(model_id, json) }
nvidia/nemotron-3.5-lightning-30b-a3b
059708fd83da7062-0
059708fd83da7062
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/status/adapters/mod.rs
file
mod.rs
src/status/adapters/mod.rs
1
62
62
Write a Rust function named `normalize_component_status` that takes a string slice `&str` and returns a `String`. The function should normalize component status strings from various monitoring platforms into a consistent lowercase format. It must map Instatus's UPPERCASECONCATENATED strings such as `OPERATIONAL`, `DEGR...
pub(crate) mod betterstack; pub(crate) mod fallback; pub(crate) mod google; pub(crate) mod instatus; pub(crate) mod onlineornot; pub(crate) mod status_io; pub(crate) mod statuspage; // --------------------------------------------------------------------------- // Normalize component status strings from various platfor...
nvidia/nemotron-3.5-lightning-30b-a3b
bcd58b3d245f8cf9-0
bcd58b3d245f8cf9
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/status/adapters/fallback.rs
file
fallback.rs
src/status/adapters/fallback.rs
1
42
42
I need a Rust function that converts an API status check response into a `FallbackSnapshot` struct. The function should accept a response containing a provider status and links, extract the provider name as the snapshot label, convert the status into a `ProviderHealth` value, and map the status page URL, fallback URL, ...
use serde::Deserialize; use crate::status::types::{FallbackSnapshot, ProviderHealth}; impl FallbackSnapshot { pub(crate) fn from_api_status(payload: ApiStatusCheckResponse) -> Self { Self { label: payload.api.name, health: ProviderHealth::from_api_status(&payload.api.status), ...
nvidia/nemotron-3.5-lightning-30b-a3b
d4caf16705019d40-0
d4caf16705019d40
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/styles.rs
file
styles.rs
src/cli/styles.rs
1
191
191
I need a Rust module that provides terminal styling utilities for a TUI/CLI, including a TTY-detection function using std::sync::OnceLock and std::io::stdout().is_terminal(), color constants CODE_BG and INPUT_BG as crossterm::style::Color::Rgb, and functions header_cell bold_cell green_cell yellow_cell dim_cell returni...
use std::io::IsTerminal; // ── Color constants (crossterm) ────────────────────────────────────── pub const CODE_BG: crossterm::style::Color = crossterm::style::Color::Rgb { r: 50, g: 40, b: 25, }; pub const INPUT_BG: crossterm::style::Color = crossterm::style::Color::Rgb { r: 60, g: 60, b: 60,...
nvidia/nemotron-3.5-lightning-30b-a3b
6b216fe1928b07fb-0
6b216fe1928b07fb
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/main.rs
file
main.rs
src/main.rs
1
226
226
Write a Rust CLI module that is the main entry point for a `models` command-line tool acting as a fast TUI and CLI for browsing AI models, benchmarks, and coding agents. The module must define a `Cli` struct derived from `clap::Parser` with an optional `Commands` subcommand enum that includes variants for `list` (with ...
mod agents; mod api; mod benchmarks; mod cli; mod config; mod data; mod formatting; mod provider_category; mod status; mod tui; use std::path::PathBuf; use anyhow::Result; use clap::{CommandFactory, Parser, Subcommand}; use clap_complete::Shell; #[derive(Parser)] #[command(name = "models")] #[command(about = "CLI/TU...
nvidia/nemotron-3.5-lightning-30b-a3b
0d1089b7722fb4e7-0
0d1089b7722fb4e7
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/tui/agents/mod.rs
file
mod.rs
src/tui/agents/mod.rs
1
4
4
I'm organizing the TUI module structure and need a Rust module file that publicly declares an `app` submodule and re-exports all its items at the crate root, and also declares a `render` submodule with visibility restricted to `crate::tui`. Please generate the appropriate `pub mod` and `pub use` statements.
pub mod app; pub(in crate::tui) mod render; pub use app::*;
nvidia/nemotron-3.5-lightning-30b-a3b
f8a3b62c3ae04e9c-0
f8a3b62c3ae04e9c
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/status/adapters/onlineornot.rs
file
onlineornot.rs
src/status/adapters/onlineornot.rs
1
166
166
I need a Rust function that parses an OnlineOrNot API status response into a structured `OfficialSnapshot`. The function should take an `OfficialStatusSource` and a JSON string body, extract the `status` field (supporting both plain strings like `"degraded"` and object-form `{"description": "..."}`), map it to `Provide...
use serde_json::Value; use super::normalize_component_status; use crate::status::types::{ available_detail_state, ActiveIncident, ComponentStatus, OfficialSnapshot, OfficialStatusSource, ProviderHealth, ScheduledMaintenance, StatusDetailSource, StatusSourceMethod, }; pub(crate) fn parse_onlineornot( s...
nvidia/nemotron-3.5-lightning-30b-a3b
e1dd02ada1486412-0
e1dd02ada1486412
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/agents/loader.rs
file
loader.rs
src/agents/loader.rs
1
32
32
I need a Rust module that loads an embedded agents configuration from a compile-time JSON string included via `include_str!`, parses it into a typed `AgentsFile` structure using `serde_json`, and returns a `Result` with proper error context via `anyhow`. Additionally, provide a function to load agents from a custom fil...
use anyhow::{Context, Result}; use std::path::Path; use super::data::AgentsFile; const EMBEDDED_AGENTS: &str = include_str!("../../data/agents.json"); pub fn load_agents() -> Result<AgentsFile> { serde_json::from_str(EMBEDDED_AGENTS).context("Failed to parse embedded agents.json") } /// Load agents from custom ...
nvidia/nemotron-3.5-lightning-30b-a3b
b98ba8133d8bcba8-0
b98ba8133d8bcba8
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/tui/benchmarks/mod.rs
file
mod.rs
src/tui/benchmarks/mod.rs
1
6
6
Write a Rust module file for a TUI benchmarks screen that declares four submodules app compare radar and render with compare and render having internal crate visibility and re-exports the app module's public API so it is available to the parent module.
pub mod app; pub(in crate::tui) mod compare; pub mod radar; pub(in crate::tui) mod render; pub use app::*;
nvidia/nemotron-3.5-lightning-30b-a3b
661332b324db63dd-0
661332b324db63dd
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/cli/agents_ui.rs
file
agents_ui.rs
src/cli/agents_ui.rs
1
526
526
I need a Rust module that implements a TUI for browsing AI model releases and agent sources. It must include a ReleaseBrowser struct and browse_releases function that displays a paginated table of release items with a changelog preview, navigation via j/k or arrow keys, and returns the selected ReleaseBrowserItem or No...
use std::time::Duration; use anyhow::Result; use crossterm::event::{self, Event, KeyCode, KeyEventKind}; use ratatui::{ layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{ Block, Borders, Cell as TuiCell, HighlightSpacing, Paragraph, Row as T...
nvidia/nemotron-3.5-lightning-30b-a3b
a6d069f450b47987-0
a6d069f450b47987
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/status/mod.rs
file
mod.rs
src/status/mod.rs
1
10
10
I need a Rust module file for a `status` module in a TUI/CLI application that browses AI models. The module should privately declare submodules `assessment` and `types`, and publicly declare submodules `adapters`, `fetch`, and `registry`. The `fetch` module must expose a `StatusFetcher` trait and a `StatusFetchResult` ...
mod assessment; mod types; pub mod adapters; pub mod fetch; pub mod registry; pub use fetch::{StatusFetchResult, StatusFetcher}; pub use registry::*; pub use types::*;
nvidia/nemotron-3.5-lightning-30b-a3b
01c796b657c16749-0
01c796b657c16749
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/tui/widgets/mod.rs
file
mod.rs
src/tui/widgets/mod.rs
1
6
6
I need a Rust module file that declares four public sub-modules—`comparison_legend`, `scroll_offset`, `scrollable_panel`, and `soft_card`—and re-exports the `ScrollOffset` type from the `scroll_offset` module using a `pub use` statement. The file should contain only module declarations and the re-export, with no additi...
pub mod comparison_legend; pub mod scroll_offset; pub mod scrollable_panel; pub mod soft_card; pub use scroll_offset::ScrollOffset;
nvidia/nemotron-3.5-lightning-30b-a3b
1cf7708c42a9c7f4-0
1cf7708c42a9c7f4
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/tui/status/mod.rs
file
mod.rs
src/tui/status/mod.rs
1
6
6
I need a Rust module file for a TUI status component that publicly re-exports an app module for the main status application interface, and internally defines three modules—detail, overall, and render—with pub(in crate::tui) visibility to handle status tracking, overall computation, and rendering respectively. Please pr...
pub mod app; pub(in crate::tui) mod detail; pub(in crate::tui) mod overall; pub(in crate::tui) mod render; pub use app::*;
nvidia/nemotron-3.5-lightning-30b-a3b
fcddb57bad66c6d5-0
fcddb57bad66c6d5
reyamira/models
https://github.com/reyamira/models
73997bf31e5bca7f59b44979c1cf943cf74487e6
MIT
src/tui/status/overall.rs
file
overall.rs
src/tui/status/overall.rs
1
547
547
Write a Rust module that implements a TUI status dashboard for AI model providers. It must render an overall status view with an operational ratio gauge, panels for active incidents, service degradation, and maintenance outlook. The layout should adapt between stacked and side-by-side arrangements based on screen width...
use crate::status::ProviderHealth; use crate::tui::ui::{status_health_icon, status_health_style}; use crate::tui::widgets::scroll_offset::ScrollOffset; use crate::tui::widgets::scrollable_panel::ScrollablePanel; use crate::tui::widgets::soft_card::SoftCard; use ratatui::{ layout::{Constraint, Direction, Layout, Rec...
nvidia/nemotron-3.5-lightning-30b-a3b
b84c2b4035c481b5-0
b84c2b4035c481b5
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-cli/src/main.rs
file
main.rs
flowcat-cli/src/main.rs
1
78
78
I need a Rust CLI tool called `flowcat` that runs two credential-free runtime demos. The first, `pipeline`, should implement an in-process `FrameProcessor` pipeline with a synthetic 1-second, 16 kHz sine wave source, passing through an identity echo processor and a trivial tap, while a `FrameObserver` counts the audio ...
// SPDX-License-Identifier: Apache-2.0 // //! Flowcat developer CLI (`flowcat`). //! //! This is the OSS demo surface — the analogue of pipecat's `examples/`. Both //! demos are credential-free and run with no external service, so they exercise //! the runtime in CI. //! //! 1. **`pipeline`** — an in-process, network...
nvidia/nemotron-3.5-lightning-30b-a3b
8cb0831c4f3a4636-0
8cb0831c4f3a4636
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
bench-rs/src/main.rs
file
main.rs
bench-rs/src/main.rs
1
247
247
I need a complete Rust source file that benchmarks a 7-stage asynchronous passthrough pipeline mirroring pipecat's FrameProcessor architecture. The pipeline must use bounded `tokio::sync::mpsc` channels with a capacity of 64, carry `bytes::Bytes` payloads of 160 bytes (representing 20ms @ 8kHz μ-law audio frames), and ...
// SPDX-License-Identifier: Apache-2.0 // //! Flowcat spike — Rust runtime baseline, mirroring bench/pipecat_profile.py. //! //! Same shape as the pipecat measurement: a 7-stage passthrough pipeline //! (source + 5 processors + sink) connected by bounded channels, carrying //! 160-byte (20ms @ 8kHz μ-law) audio frames....
nvidia/nemotron-3.5-lightning-30b-a3b
06047f4cce2679ab-0
06047f4cce2679ab
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-agent/src/lib.rs
file
lib.rs
flowcat-agent/src/lib.rs
1
30
30
Generate the `lib.rs` file for a Rust crate named `flowcat-agent` that implements a declarative, graph-based conversation agent. The file must begin with an Apache-2.0 license header and a crate-level doc comment explaining that agents are defined as node/edge graphs rather than hand-written `AgentBrain` code. The `eng...
// SPDX-License-Identifier: Apache-2.0 // //! `flowcat-agent` — a declarative, graph-based conversation agent for Flowcat. //! //! Define an agent as a node/edge graph (the same `graph_spec` JSON an editor //! produces) instead of hand-writing an `AgentBrain` in Rust. The [`Engine`] is //! pure logic: parse the graph, ...
nvidia/nemotron-3.5-lightning-30b-a3b
a72dbe8279c3d20e-0
a72dbe8279c3d20e
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/agent/voicemail.rs
file
voicemail.rs
flowcat-core/src/agent/voicemail.rs
1
376
376
I need a Rust module that implements a heuristic voicemail detector as a FrameProcessor for a flowcat-like agent system. The detector should classify incoming call frames as either conversation or voicemail using two signals: a transcript-based phrase match against a curated list of voicemail greeting phrases, and a VA...
// SPDX-License-Identifier: Apache-2.0 // //! Voicemail / answering-machine detection (pure logic, no network). //! //! pipecat's `VoicemailDetector` is a *parallel LLM classifier* (it asks a text //! LLM "CONVERSATION or VOICEMAIL?"). That needs a network LLM, so it is out of //! this pure-logic scope. The flowcat det...
nvidia/nemotron-3.5-lightning-30b-a3b
303e39ac590d7731-0
303e39ac590d7731
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/agent/mod.rs
file
mod.rs
flowcat-core/src/agent/mod.rs
1
91
91
I need a test harness module for a Rust frame-processing library that lets me drive a `dyn FrameProcessor` through a single capture channel and collect emitted frames. The API should provide an async `drive` function that takes a processor, a vector of input frames, and a direction, and returns all frames pushed onto t...
// SPDX-License-Identifier: Apache-2.0 // //! Higher-level **pure-logic** conversation features (no network). //! //! These are frame-logic processors that decide things from the existing frame //! stream without any outbound network call — so they live in core (the //! networked pieces, MCP-as-processor + the carrier-...
nvidia/nemotron-3.5-lightning-30b-a3b
a68f355edd869819-0
a68f355edd869819
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/brain.rs
file
brain.rs
flowcat-core/src/brain.rs
1
53
53
I need a Rust trait called `AgentBrain` that implements a conversation decision-maker seam for a flow-based AI agent system. The trait should own the system prompt and tool set for the current state, decide what a tool call means, and report completion plus collected variables. It must be synchronous, pure decision log...
// SPDX-License-Identifier: Apache-2.0 // //! The conversation decision-maker seam. //! //! The embedder implements [`AgentBrain`] over its own engine; flowcat-core //! ships a demo brain. The brain owns the system prompt + tool set for the //! current state and decides what a tool call means (see DESIGN.md //! "Trait ...
nvidia/nemotron-3.5-lightning-30b-a3b
7d79ef6245126929-0
7d79ef6245126929
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/agent/wakeword.rs
file
wakeword.rs
flowcat-core/src/agent/wakeword.rs
1
463
463
I need a pure Rust wake-word gating module for a frame transcription stream that mirrors pipecat's wake filters. It must include a WakeCheckFilter that buffers per-user transcriptions and only passes Frame::Transcription through after detecting a case-insensitive whole-word wake phrase, with a keepalive window to keep ...
// SPDX-License-Identifier: Apache-2.0 // //! Wake-word gating (pure logic, no network). //! //! Ports pipecat's wake filters (`processors/filters/wake_check_filter.py`, //! `wake_notifier_filter.py`) to the flowcat frame stream: //! //! - [`WakeCheckFilter`] — buffers per-user transcription text and only lets a //! ...
nvidia/nemotron-3.5-lightning-30b-a3b
b32b71e6e96a7aa5-0
b32b71e6e96a7aa5
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/error.rs
file
error.rs
flowcat-core/src/error.rs
1
58
58
I need a Rust error enum that will be the sole error type returned by all fallible methods in a library crate. It must use the `thiserror` crate so that `Display` and `Error` impls are generated automatically. The enum should have variants for transport, serializer, realtime LLM, codec, session, network, and protocol e...
// SPDX-License-Identifier: Apache-2.0 // //! The crate-wide error type. //! //! Every fallible trait method in flowcat-core returns `Result<_, FlowcatError>`. use thiserror::Error; /// Errors surfaced by the Flowcat runtime. /// /// Variants are intentionally broad; implementation agents may add fields or /// new va...
nvidia/nemotron-3.5-lightning-30b-a3b
176b142d00b30def-0
176b142d00b30def
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/pipeline/parallel.rs
file
parallel.rs
flowcat-core/src/pipeline/parallel.rs
1
409
409
I need a Rust `FrameProcessor` implementation of a `ParallelPipeline` struct that performs fan-out/fan-in across multiple pipeline branches with `meta.id` deduplication and synchronized lifecycle frame handling (Start/End/Cancel) across all branches before forwarding. The block should accept a frame at its head, fan it...
// SPDX-License-Identifier: Apache-2.0 // //! `ParallelPipeline` — fan-out / fan-in with lifecycle sync //! (PROCESSOR-DESIGN §3.2). //! //! A frame entering the parallel block is queued into **every** branch's head. //! Each branch's tail output funnels into a single downstream, **de-duplicated by //! `meta.id`** (a f...
nvidia/nemotron-3.5-lightning-30b-a3b
139c7c09bc48ff80-0
139c7c09bc48ff80
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/observer/mod.rs
file
mod.rs
flowcat-core/src/observer/mod.rs
1
583
583
Write a Rust module for a pipeline observer system that enables non-intrusive frame monitoring without participating in the processing chain. The module must define a `FrameObserver` async trait with `on_process`, `on_push`, and `on_pipeline_started` methods. Provide a cheaply clonable `Observer` struct that fan-outs c...
// SPDX-License-Identifier: Apache-2.0 // //! Non-intrusive pipeline monitoring (PROCESSOR-DESIGN §5.1). //! //! A [`FrameObserver`] sees every processed/pushed frame without sitting in the //! chain — the seam OpenTelemetry/Sentry/Langfuse/RTVI observers plug into. The //! [`Observer`] fan-out is cheaply clonable; hoo...
nvidia/nemotron-3.5-lightning-30b-a3b
7faaf0053fa6328e-0
7faaf0053fa6328e
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/pipeline/runner.rs
file
runner.rs
flowcat-core/src/pipeline/runner.rs
1
184
184
I need a Rust module implementing a `PipelineRunner` that supervises `PipelineTask` instances with graceful SIGINT/SIGTERM cancellation. The runner is constructed with `handle_sigint` and `handle_sigterm` flags, stores `CancellationToken`s in a `Mutex<Vec<CancellationToken>>`, and provides a `run` method that races a t...
// SPDX-License-Identifier: Apache-2.0 // //! `PipelineRunner` — supervise tasks + signals (PROCESSOR-DESIGN §4.2). //! //! Runs one or many [`PipelineTask`]s and installs SIGINT/SIGTERM handlers that //! `cancel_all()` for graceful drain (the prod deploy-cutover drain story relies //! on SIGTERM grace). Mirrors pipeca...
nvidia/nemotron-3.5-lightning-30b-a3b
a507e646a06af451-0
a507e646a06af451
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/pipeline/s2s_test_mocks.rs
file
s2s_test_mocks.rs
flowcat-core/src/pipeline/s2s_test_mocks.rs
1
594
594
I need a test-only Rust module for the S2S pipeline that provides scripted mocks enabling end-to-end deterministic exercise of the realtime pipeline without network or Gemini. The module should mock the media socket (yielding Plivo start/media/stop frames and capturing outbound audio), the realtime LLM (emitting a fixe...
// SPDX-License-Identifier: Apache-2.0 // //! Shared scripted mock seams for the S2S equivalence tests (test-only). //! //! These scripted mocks drive the S2S processor [`PipelineTask`](crate::pipeline::PipelineTask) //! in `s2s::tests` (the §7.2 behaviour gate), letting the realtime pipeline be //! exercised end-to-en...
nvidia/nemotron-3.5-lightning-30b-a3b
8d3cc2f9ee5f4d38-0
8d3cc2f9ee5f4d38
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/realtime/service_adapter.rs
file
service_adapter.rs
flowcat-core/src/realtime/service_adapter.rs
1
173
173
I need a Rust struct `ServiceRealtimeAdapter` that wraps any `RealtimeLlmService` and implements the `RealtimeLlm` and `RealtimeKickoff` traits for use in the flowcat pipeline. The adapter should delegate `connect`, `update_system`, `send_tool_result`, `next_event`, and `poll_event` to the inner service. For `send_audi...
// SPDX-License-Identifier: Apache-2.0 // //! Bridge: [`RealtimeLlmService`] → [`RealtimeLlm`] + [`RealtimeKickoff`]. //! //! flowcat has two realtime trait surfaces: the s2s pipeline //! ([`build_s2s_task`](crate::pipeline::build_s2s_task)) is generic over //! [`RealtimeLlm`] + [`RealtimeKickoff`] (which [`GeminiLive`...
nvidia/nemotron-3.5-lightning-30b-a3b
2c4ef5bcf6ba4f13-0
2c4ef5bcf6ba4f13
AreevAI/flowcat
https://github.com/AreevAI/flowcat
9eb2999c3325859d0b9afd233b97f22774e577df
Apache-2.0
flowcat-core/src/processor/runtime.rs
file
runtime.rs
flowcat-core/src/processor/runtime.rs
1
432
432
How do I implement a per-processor task loop in Rust that prioritizes system interruption frames over data frames, drains interruptible frames on interruption without losing buffered downstream terminals, and converts `process_frame` errors into non-fatal upstream errors? The loop should bias-select the system channel ...
// SPDX-License-Identifier: Apache-2.0 // //! The framework-owned per-processor task loop (PROCESSOR-DESIGN §2.2/§2.3/§2.5). //! //! Two channels per processor so `System` frames jump ahead of `Data`/`Control` //! (pipecat does this with a `PriorityQueue`, `frame_processor.py:119`; a second //! channel is the cheaper, ...
nvidia/nemotron-3.5-lightning-30b-a3b