add framework for 93 (WIP)

This commit is contained in:
Dr. Matthias Ratajczak
2023-06-20 16:20:46 +02:00
parent e76f3199de
commit bf248f902c
2 changed files with 42 additions and 10 deletions
+1
View File
@@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
itertools = "*"
+41 -10
View File
@@ -1,3 +1,5 @@
use itertools::Itertools;
type Num = f64;
fn main() {
@@ -18,21 +20,50 @@ fn main() {
}
}
fn recurse(array: &[Num]) -> Vec<Num> {
if array.len() == 2 {
let [a, b] = array else { panic!() };
let mut v = vec![];
for ops in Operations::iter() {
v.push(ops(*a, *b));
}
v
} else {
let a = array[0];
let b = array[1];
let mut v = vec![];
for ops in Operations::iter() {
v.push(ops(a, b));
}
}
}
struct Digits(Num, Num, Num, Num);
impl Digits {
fn all_possible_integers(&self) -> Vec<u32> {
let a = self.0;
let b = self.1;
let c = self.2;
let d = self.3;
let array = [self.0, self.1, self.2, self.3];
let outcomes: Vec<_> = Operations::new()
.map(|f| f(a, b) as u32)
.filter(|i| *i > 0)
.collect();
array.into_iter().permutations(4).next().map(|a| {
for ops in Operations::iter() {
let x = ops(a[0], a[1]);
}
});
dbg!(outcomes)
// dbg!(v);
todo!()
// let outcomes: Vec<_> = Operations::new()
// .map(|f| f(a, b) as u32)
// .filter(|i| *i > 0)
// .collect();
// dbg!(outcomes)
}
}
@@ -58,7 +89,7 @@ impl Iterator for Operations {
}
impl Operations {
fn new() -> Self {
fn iter() -> Self {
Self { last: 0 }
}
}