testing and fixing
This commit is contained in:
@@ -18,4 +18,26 @@ pub fn parse_abbreviated_number(s: &str) -> Option<u32> {
|
||||
_ => return None,
|
||||
};
|
||||
num_part.parse::<f64>().ok().map(|n| (n * multiplier) as u32)
|
||||
}
|
||||
|
||||
pub fn interleave<T: Clone>(lists: &[Vec<T>]) -> Vec<T> {
|
||||
let mut result = Vec::new();
|
||||
|
||||
if lists.is_empty() {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find the maximum length among the lists
|
||||
let max_len = lists.iter().map(|l| l.len()).max().unwrap_or(0);
|
||||
|
||||
// Interleave elements
|
||||
for i in 0..max_len {
|
||||
for list in lists {
|
||||
if let Some(item) = list.get(i) {
|
||||
result.push(item.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
Reference in New Issue
Block a user