-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69bf158
commit e77e9ba
Showing
10 changed files
with
150 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cpy a b | ||
dec b | ||
cpy a d | ||
cpy 0 a | ||
cpy b c | ||
inc a | ||
dec c | ||
jnz c -2 | ||
dec d | ||
jnz d -5 | ||
dec b | ||
cpy b c | ||
cpy c d | ||
dec d | ||
inc c | ||
jnz d -2 | ||
tgl c | ||
cpy -16 c | ||
jnz 1 c | ||
cpy 96 c | ||
jnz 91 d | ||
inc a | ||
inc d | ||
jnz d -2 | ||
inc c | ||
jnz c -5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use super::assembunny::Assembunny; | ||
|
||
// pub fn day_12_v1(input: impl Into<String>) -> i64 { | ||
// } | ||
// pub fn day_12_v2(input: impl Into<String>) -> i64 { | ||
// let mut bunny: Assembunny = Assembunny::from_input(&input.into()); | ||
// bunny.set_register("c", 1); | ||
// bunny.run(); | ||
|
||
// bunny.registers[0] | ||
// } | ||
|
||
pub fn day_23_v1(input: impl Into<String>) -> i64 { | ||
let mut bunny: Assembunny = Assembunny::from_input(&input.into()); | ||
bunny.set_register("a", 7); | ||
bunny.run(); | ||
|
||
bunny.registers[0] | ||
} | ||
|
||
pub fn day_23_v2(input: impl Into<String>) -> i64 { | ||
let mut bunny: Assembunny = Assembunny::from_input(&input.into()); | ||
bunny.set_register("a", 12); | ||
bunny.run(); | ||
|
||
bunny.registers[0] | ||
} | ||
|
||
solvable!(day_23, day_23_v1, day_23_v2, i64); | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn works_with_samples_v1() { | ||
let sample_one = "cpy 2 a\n\ | ||
tgl a\n\ | ||
tgl a\n\ | ||
tgl a\n\ | ||
cpy 1 a\n\ | ||
dec a\n\ | ||
dec a"; | ||
assert_eq!(day_23_v1(sample_one), 3); | ||
} | ||
} |