fix commented out code
This commit is contained in:
+30
-23
@@ -9,34 +9,41 @@ use primes::Primes;
|
|||||||
type Int = u64;
|
type Int = u64;
|
||||||
|
|
||||||
// EXAMPLE 1
|
// EXAMPLE 1
|
||||||
// const MIN_VALUE: Int = 10;
|
// const SEARCH_MIN: Int = 10;
|
||||||
// const MAX_VALUE: Int = 99;
|
// const SEARCH_MAX: Int = 99;
|
||||||
// const LENGTH: usize = 2;
|
// const AMOUNT_OF_DIGITS_IN_NUMBER: usize = 2;
|
||||||
// const MIN_LENGTH: usize = 1;
|
// const MIN_PATTERN_LENGTH: usize = 1;
|
||||||
|
// const FAMILY_SIZE: usize = 6;
|
||||||
|
|
||||||
// EXAMPLE 2
|
// EXAMPLE 2
|
||||||
// const MIN_VALUE: Int = 10_000;
|
// const SEARCH_MIN: Int = 10_000;
|
||||||
// const MAX_VALUE: Int = 99_999;
|
// const SEARCH_MAX: Int = 99_999;
|
||||||
// const LENGTH: usize = 5;
|
// const AMOUNT_OF_DIGITS_IN_NUMBER: usize = 5;
|
||||||
// const MIN_LENGTH: usize = 2;
|
// const MIN_PATTERN_LENGTH: usize = 1;
|
||||||
|
// const FAMILY_SIZE: usize = 7;
|
||||||
|
|
||||||
// FINAL
|
// FINAL
|
||||||
const MIN_VALUE: Int = 100_000;
|
const SEARCH_MIN: Int = 100_000;
|
||||||
const MAX_VALUE: Int = 999_999;
|
const SEARCH_MAX: Int = 999_999;
|
||||||
const LENGTH: usize = 6;
|
const AMOUNT_OF_DIGITS_IN_NUMBER: usize = 6;
|
||||||
const MIN_LENGTH: usize = 2;
|
const MIN_PATTERN_LENGTH: usize = 2;
|
||||||
const TARGET_LENGTH: usize = 8;
|
const FAMILY_SIZE: usize = 8;
|
||||||
|
|
||||||
const MAX_LENGTH: usize = LENGTH - 1;
|
const MAX_PATTERN_LENGTH: usize = AMOUNT_OF_DIGITS_IN_NUMBER - 1;
|
||||||
const DIGITS: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
const NUMBER_OF_DIGITS: usize = 10;
|
||||||
|
const DIGITS: [u8; NUMBER_OF_DIGITS] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let all_primes = Primes::get_between(MIN_VALUE, MAX_VALUE);
|
let all_primes = Primes::get_between(SEARCH_MIN, SEARCH_MAX);
|
||||||
let mut processed_cases = HashSet::with_capacity(MIN_VALUE as usize);
|
let mut processed_cases = HashSet::with_capacity(SEARCH_MIN as usize);
|
||||||
let mut primes_matching_pattern = Vec::with_capacity(TARGET_LENGTH);
|
let mut primes_matching_pattern = Vec::with_capacity(FAMILY_SIZE);
|
||||||
let mut case_buf = String::with_capacity(LENGTH);
|
let mut case_buf = String::with_capacity(AMOUNT_OF_DIGITS_IN_NUMBER);
|
||||||
|
|
||||||
for pattern in PositionCombinations::new(MIN_LENGTH, MAX_LENGTH, LENGTH) {
|
for pattern in PositionCombinations::new(
|
||||||
|
MIN_PATTERN_LENGTH,
|
||||||
|
MAX_PATTERN_LENGTH,
|
||||||
|
AMOUNT_OF_DIGITS_IN_NUMBER,
|
||||||
|
) {
|
||||||
for prime in &all_primes.vector {
|
for prime in &all_primes.vector {
|
||||||
primes_matching_pattern.clear();
|
primes_matching_pattern.clear();
|
||||||
|
|
||||||
@@ -59,7 +66,7 @@ fn main() {
|
|||||||
primes_matching_pattern.push(could_be_prime);
|
primes_matching_pattern.push(could_be_prime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if primes_matching_pattern.len() == TARGET_LENGTH {
|
if primes_matching_pattern.len() == FAMILY_SIZE {
|
||||||
println!("{primes_matching_pattern:#?}");
|
println!("{primes_matching_pattern:#?}");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -68,8 +75,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn enough_digits_left(i: usize, primes_len: usize) -> bool {
|
fn enough_digits_left(i: usize, primes_len: usize) -> bool {
|
||||||
// are there enough digits left in the loop to achieve the required TARGET_LENGTH?
|
// are there enough digits left in the loop to achieve the required FAMILY_SIZE?
|
||||||
i - primes_len + TARGET_LENGTH <= 10
|
i - primes_len + FAMILY_SIZE <= NUMBER_OF_DIGITS
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_case_string(digits: &[u8], pattern: &[bool], buf: &mut String) {
|
fn get_case_string(digits: &[u8], pattern: &[bool], buf: &mut String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user