divide repository in src and lib

This commit is contained in:
timeshifter committed 2022-08-14 21:14:01 +02:00
1 parent 4bac3290e5
commit a43cdc4494
19 files changed
+41 -10

No files matched your search

-1
View File
@@ -131,7 +131,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
+2
View File
@@ -0,0 +1,2 @@
/target
/Cargo.lock
+8
View File
@@ -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]
File renamed without changes.
+2
View File
@@ -0,0 +1,2 @@
/target
/Cargo.lock
+8
View File
@@ -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 {
($($arg:tt)*) => (#[cfg(debug_assertions)] println!($($arg)*));
}
+1 -1
View File
@@ -1,5 +1,5 @@
[package]
name = "euler51"
name = "primes"
version = "0.1.0"
edition = "2021"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+10
View File
@@ -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"}
View File
Whitespace-only changes.
@@ -1,11 +1,8 @@
mod combination;
mod primes;
extern crate combination;
extern crate primes;
#[macro_use]
mod macros;
use crate::combination::{PositionCombinations, ToString};
use crate::primes::Primes;
use combination::PositionCombinations;
use primes::Primes;
type Int = u64;
@@ -40,7 +37,6 @@ fn main() {
let all_primes = Primes::get_between(MIN_VALUE, MAX_VALUE);
let mut best_of_all_combinations = vec![];
for pattern in PositionCombinations::new(MIN_LENGTH, MAX_LENGTH, LENGTH) {
dbg_println!("{}", pattern.to_string());
let mut best_this_combination = vec![];
let mut primes_to_check = all_primes.clone();
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()
}
trait ToString {
fn to_string(&self) -> String;
}
impl ToString for Vec<u8> {
fn to_string(&self) -> String {
self.iter().map(|d| d.to_string()).collect()