divide repository in src and lib
This commit is contained in:
@@ -131,7 +131,6 @@ dist/
|
|||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
lib/
|
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
/Cargo.lock
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "combination"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
/Cargo.lock
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#[allow(unused_macros)]
|
||||||
|
|
||||||
macro_rules! dbg_println {
|
macro_rules! dbg_println {
|
||||||
($($arg:tt)*) => (#[cfg(debug_assertions)] println!($($arg)*));
|
($($arg:tt)*) => (#[cfg(debug_assertions)] println!($($arg)*));
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "euler51"
|
name = "primes"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "euler51"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
primes = {version = "*", path = "../../lib/primes"}
|
||||||
|
combination = {version = "*", path = "../../lib/combination"}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
mod combination;
|
extern crate combination;
|
||||||
mod primes;
|
extern crate primes;
|
||||||
|
|
||||||
#[macro_use]
|
use combination::PositionCombinations;
|
||||||
mod macros;
|
use primes::Primes;
|
||||||
|
|
||||||
use crate::combination::{PositionCombinations, ToString};
|
|
||||||
use crate::primes::Primes;
|
|
||||||
|
|
||||||
type Int = u64;
|
type Int = u64;
|
||||||
|
|
||||||
@@ -40,7 +37,6 @@ fn main() {
|
|||||||
let all_primes = Primes::get_between(MIN_VALUE, MAX_VALUE);
|
let all_primes = Primes::get_between(MIN_VALUE, MAX_VALUE);
|
||||||
let mut best_of_all_combinations = vec![];
|
let mut best_of_all_combinations = vec![];
|
||||||
for pattern in PositionCombinations::new(MIN_LENGTH, MAX_LENGTH, LENGTH) {
|
for pattern in PositionCombinations::new(MIN_LENGTH, MAX_LENGTH, LENGTH) {
|
||||||
dbg_println!("{}", pattern.to_string());
|
|
||||||
let mut best_this_combination = vec![];
|
let mut best_this_combination = vec![];
|
||||||
let mut primes_to_check = all_primes.clone();
|
let mut primes_to_check = all_primes.clone();
|
||||||
while let Some(first) = primes_to_check.pop() {
|
while let Some(first) = primes_to_check.pop() {
|
||||||
@@ -80,6 +76,10 @@ fn get_longest(mut vec: Vec<Vec<Int>>, print: bool) -> Vec<Int> {
|
|||||||
vec.into_iter().find(|v| v.len() == length).unwrap()
|
vec.into_iter().find(|v| v.len() == length).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait ToString {
|
||||||
|
fn to_string(&self) -> String;
|
||||||
|
}
|
||||||
|
|
||||||
impl ToString for Vec<u8> {
|
impl ToString for Vec<u8> {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
self.iter().map(|d| d.to_string()).collect()
|
self.iter().map(|d| d.to_string()).collect()
|
||||||
Reference in New Issue
Block a user