summaryrefslogtreecommitdiff
path: root/2015/rust
diff options
context:
space:
mode:
authorcos <cos>2019-12-11 20:06:57 +0100
committercos <cos>2019-12-11 20:06:57 +0100
commit1e38aeed2565578b98bbb60b6a4d46ad0739d915 (patch)
tree31f5755e84f86e4a3bb70bae3bc746831608bb54 /2015/rust
parent9ab2a7320f7d1eeee9a42198c2cb1667612a62d1 (diff)
downloadadventofcode-1e38aeed2565578b98bbb60b6a4d46ad0739d915.zip
Add part 1 of day25, 2015
Diffstat (limited to '2015/rust')
-rw-r--r--2015/rust/day25/Cargo.toml7
-rw-r--r--2015/rust/day25/src/main.rs21
2 files changed, 28 insertions, 0 deletions
diff --git a/2015/rust/day25/Cargo.toml b/2015/rust/day25/Cargo.toml
new file mode 100644
index 0000000..304ab5f
--- /dev/null
+++ b/2015/rust/day25/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "day25"
+version = "0.1.0"
+authors = ["cos <cos>"]
+edition = "2018"
+
+[dependencies]
diff --git a/2015/rust/day25/src/main.rs b/2015/rust/day25/src/main.rs
new file mode 100644
index 0000000..655c132
--- /dev/null
+++ b/2015/rust/day25/src/main.rs
@@ -0,0 +1,21 @@
+fn main() {
+ let start:u128 = 20151125;
+ let factor:u128 = 252533;
+ let div:u128 = 33554393;
+
+ let mut val:u128 = start;
+
+ let mut x = 1;
+ let mut y = 2;
+ loop {
+ val = val * factor % div;
+ if y == 2947 && x == 3029 { break; }
+ x += 1;
+ y -= 1;
+ if y == 0 {
+ y = x;
+ x = 1;
+ }
+ }
+ println!("Row: {} Column: {} Code: {}", y, x, val);
+}