Colorful numbers: Difference between revisions

m
m (rust example)
Line 2,179:
=={{header|Rust}}==
<syntaxhighlight lang="rust">use core::cmp::max;
use std::collections::HashSet;
use itertools::Itertools;
 
fn to_digits(mut n: u64, base: u64) -> Vec<u64> {
Line 2,197:
if &n > &10 {
let dig: Vec<u64> = to_digits(n, 10);
if dig.len() > products.len() || dig.contains(&1) || dig.contains(&0) {
let mut products: Vec<u64> = dig.clone().into_iter().unique().collect();
if dig.len() > products.len() || dig.contains(&1) || dig.contains(&0) {
return false;
}
let mut products: VecHashSet<u64> = dig.clone().into_iter().unique().collectHashSet::new();
for i in 0..dig.len() {
if products.contains(&dig[i]) {
return false;
}
products.insert(dig[i]);
}
for i in 0..dig.len() {
Line 2,207 ⟶ 2,213:
return false;
}
products.pushinsert(p);
}
}
4,105

edits