aboutsummaryrefslogtreecommitdiff
path: root/entries/lilylin/fractran/src/core.rs
diff options
context:
space:
mode:
authorLily Lin2022-10-25 05:46:06 +0000
committerLily Lin2022-10-25 05:46:06 +0000
commit2222d48075ab6d225f3cff7b444e35c70c7472fb (patch)
tree5e6a3d65325762ac7bfc3f9eeccfa42bbb7b4582 /entries/lilylin/fractran/src/core.rs
parentbd57417ffbfbb4c8cce53465835ddc9bdfa86dc9 (diff)
Add entries
Diffstat (limited to 'entries/lilylin/fractran/src/core.rs')
-rw-r--r--entries/lilylin/fractran/src/core.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/entries/lilylin/fractran/src/core.rs b/entries/lilylin/fractran/src/core.rs
new file mode 100644
index 0000000..2595d48
--- /dev/null
+++ b/entries/lilylin/fractran/src/core.rs
@@ -0,0 +1,40 @@
+use num_traits::Pow;
+
+pub type FracSize = u16;
+
+#[derive(Debug)]
+pub struct Program {
+ pub fractions: Vec<(FracSize, FracSize)>,
+ pub initial: u64,
+}
+
+impl Program {
+ pub fn fibonacci(i: u32) -> Program {
+ Program {
+ fractions: vec![
+ (17, 65),
+ (133, 34),
+ (17, 19),
+ (23, 17),
+ (2233, 69),
+ (23, 29),
+ (31, 23),
+ (74, 341),
+ (31, 37),
+ (41, 31),
+ (129, 287),
+ (41, 43),
+ (13, 41),
+ (1, 13),
+ (1, 3),
+ ],
+ initial: 78 * 5u64.pow(i),
+ }
+ }
+}
+
+pub trait FractranEngine<Value>: IntoIterator<Item = Value>
+where
+ Value: From<u64>,
+{
+}