diff --git a/.aoc_tiles/tiles/2024/20.png b/.aoc_tiles/tiles/2024/20.png
index 852cf09..5d13312 100644
Binary files a/.aoc_tiles/tiles/2024/20.png and b/.aoc_tiles/tiles/2024/20.png differ
diff --git a/.aoc_tiles/tiles/2024/22.png b/.aoc_tiles/tiles/2024/22.png
index 3b27ddc..56fdee5 100644
Binary files a/.aoc_tiles/tiles/2024/22.png and b/.aoc_tiles/tiles/2024/22.png differ
diff --git a/README.md b/README.md
index 46d6e9c..422c0bf 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
- 2024 - 40 ⭐ - Rust
+ 2024 - 43 ⭐ - Rust
@@ -65,4 +65,7 @@
+
+
+
diff --git a/src/day22.rs b/src/day22.rs
new file mode 100644
index 0000000..b6ff2e8
--- /dev/null
+++ b/src/day22.rs
@@ -0,0 +1,64 @@
+use aoc_runner_derive::{aoc, aoc_generator};
+
+fn evolve_secret(mut n: i64) -> i64 {
+ n = ((n * 64) ^ n) % 16777216;
+ n = ((n / 32) ^ n) % 16777216;
+ n = ((n * 2048) ^ n) % 16777216;
+ n
+}
+
+fn rounds(mut secret: i64, n: i64) -> i64 {
+ for _ in 0..n {
+ secret = evolve_secret(secret)
+ }
+ secret
+}
+
+fn parse(input: &str) -> Vec {
+ input.lines().map(|l| l.parse().unwrap()).collect()
+}
+
+#[aoc(day22, part1)]
+fn part1(input: &str) -> i64 {
+ let secrets = parse(input);
+
+ secrets.iter().map(|s| rounds(*s, 2000)).sum::()
+}
+
+#[aoc(day22, part2)]
+fn part2(input: &str) -> i64 {
+ todo!()
+}
+
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ const EXAMPLE: &str = "1
+10
+100
+2024";
+
+ #[test]
+ fn evolution() {
+ assert_eq!(evolve_secret(123), 15887950);
+ assert_eq!(evolve_secret(15887950), 16495136);
+ assert_eq!(evolve_secret(16495136), 527345);
+ }
+
+ #[test]
+ fn test_rounds() {
+ assert_eq!(rounds(1, 2000), 8685429);
+ assert_eq!(rounds(10, 2000), 4700978);
+ }
+
+ #[test]
+ fn part1_example() {
+ assert_eq!(part1(EXAMPLE),37327623);
+ }
+
+ #[test]
+ fn part2_example() {
+ assert_eq!(part2(EXAMPLE), 0);
+ }
+}
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 0a534d1..320bb98 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,6 +12,7 @@ pub mod day19;
pub mod day2;
pub mod day20;
pub mod day21;
+pub mod day22;
pub mod day3;
pub mod day4;
pub mod day5;