Sha256: e8452b4de5251d4dd246909938cd417c13f73d01c9257899452f65f271ecf23e
Contents?: true
Size: 434 Bytes
Versions: 24
Compression:
Stored size: 434 Bytes
Contents
pub fn is_valid(candidate: &str) -> bool { if candidate.chars().any(|c| c.is_alphabetic()) || candidate.chars().count() == 1 { return false; } candidate.chars() .filter_map(|c| c.to_digit(10)) .rev() .enumerate() .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 }) .map(|digit| if digit > 9 { digit - 9 } else { digit }) .sum::<u32>() % 10 == 0 }
Version data entries
24 entries across 24 versions & 1 rubygems