Rare numbers: Difference between revisions
Content deleted Content added
→{{header|Raku}}: add alternative |
m →{{header|Rust}}: fix typo and revert a change |
||
Line 5,469: | Line 5,469: | ||
let diffs1: Vec<i8> = vec![0, 1, 4, 5, 6]; |
let diffs1: Vec<i8> = vec![0, 1, 4, 5, 6]; |
||
// all possible digits pairs to |
// all possible digits pairs to calculate potential diffs |
||
let pairs = (0_i8..=9) |
let pairs = (0_i8..=9) |
||
.cartesian_product(0_i8..=9) |
.cartesian_product(0_i8..=9) |
||
Line 5,503: | Line 5,503: | ||
.collect::<Vec<u64>>(); |
.collect::<Vec<u64>>(); |
||
// create a cartesian product for all |
// create a cartesian product for all potential diff numbers |
||
// for the first use the very short one, for all other the complete 19 element |
// for the first use the very short one, for all other the complete 19 element |
||
let diff_list_iter = (0_u8..(d / 2)) |
let diff_list_iter = (0_u8..(d / 2)) |
||
Line 5,521: | Line 5,521: | ||
(a, b) if (a == 4 && ![-8, -6, -4, -2, 0, 2, 4, 6, 8].contains(&b)) => false, |
(a, b) if (a == 4 && ![-8, -6, -4, -2, 0, 2, 4, 6, 8].contains(&b)) => false, |
||
(a, b) if (a == 5 && ![7, -3].contains(&b)) => false, |
(a, b) if (a == 5 && ![7, -3].contains(&b)) => false, |
||
(a, b) if (a == 6 && ![-9, -7, -5, -3, -1, 1, 3, 5, 7, 9].contains(&b)) => |
(a, b) if (a == 6 && ![-9, -7, -5, -3, -1, 1, 3, 5, 7, 9].contains(&b)) => { |
||
false |
|||
} |
|||
_ => true, |
_ => true, |
||
} |
} |