RUST CODING /** Returns the sum XXXXXXXXXXn If n is less than 0, return -1 **/ pub fn gauss(n: i32) -> i32 { unimplemented!() } /** Returns the number of elements in the list that are in the range...

RUST CODING
/**
Returns the sum 1 + 2 + ... + n
If n is less than 0, return -1
**/
pub fn gauss(n: i32) -> i32 {
unimplemented!()
}
/**
Returns the number of elements in the list that
are in the range [s,e]
**/
pub fn in_range(ls: &[i32], s: i32, e: i32) -> i32 {
unimplemented!()
}
/**
Returns true if target is a subset of set, false otherwise
Ex: [1,3,2] is a subset of [1,2,3,4,5]
**/
pub fn subset(set: &[T], target: &[T]) -> bool {
unimplemented!()
}
/**
Returns the mean of elements in ls. If the list is empty, return None
It might be helpful to use the fold method of the Iterator trait
**/
pub fn mean(ls: &[f64]) -> Option {
unimplemented!()
}
/**
Converts a binary number to decimal, where each bit is stored in order in the array
Ex: to_decimal of [1,0,1,0] returns 10
**/
pub fn to_decimal(ls: &[i32]) -> i32 {
unimplemented!()
}
/**
Decomposes an integer into its prime factors and returns them in a vector
You can assume factorize will never be passed anything less than 2
Ex: factorize of 36 should return [2,2,3,3] since 36 = 2 * 2 * 3 * 3
**/
pub fn factorize(n: u32) -> Vec {
unimplemented!()
}
/**
Takes all of the elements of the given slice and creates a new vector.
The new vector takes all the elements of the original and rotates them,
so the first becomes the last, the second becomes first, and so on.
EX: rotate [1,2,3,4] returns [2,3,4,1]
**/
pub fn rotate(lst: &[i32]) -> Vec {
unimplemented!()
}
/**
Returns true if target is a subtring of s, false otherwise
You should not use the contains function of the string library in your implementation
Ex: "ace" is a substring of "rustacean"
**/
pub fn substr(s: &String, target: &str) -> bool {
unimplemented!()
}
/**
Takes a string and returns the first longest substring of consecutive equal characters
EX: longest_sequence of "ababbba" is Some("bbb")
EX: longest_sequence of "aaabbb" is Some("aaa")
EX: longest_sequence of "xyz" is Some("x")
EX: longest_sequence of "" is None
**/
pub fn longest_sequence(s: &str) -> Option<&str> {
unimplemented!()
}
May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here