Compare commits
2 Commits
37eb9e1ab6
...
02f92114d3
Author | SHA1 | Date | |
---|---|---|---|
02f92114d3 | |||
dcbed83ea4 |
@ -3,33 +3,58 @@
|
||||
## Progress
|
||||
|
||||
| Day | Part 1 | Part 2 | Language |
|
||||
| :-: | :----: | :----: | :------- |
|
||||
| 01 | ✓ | ✓ | [Rust] |
|
||||
| 02 | ✓ | ✓ | [Rust] |
|
||||
| 03 | ✓ | ✓ | [Rust] |
|
||||
| 04 | ✓ | ✓ | [Rust] |
|
||||
| 05 | ✓ | ✓ | [Rust] |
|
||||
| 06 | ✓ | ✓ | [Rust] |
|
||||
| 07 | ✓ | ✓ | [Rust] |
|
||||
| 08 | ✓ | ✓ | [Rust] |
|
||||
| 09 | ✓ | ✓ | [Rust] |
|
||||
| 10 | ✓ | ✓ | [Rust] |
|
||||
| 11 | | | |
|
||||
| 12 | | | |
|
||||
| 13 | | | |
|
||||
| 14 | | | |
|
||||
| 15 | | | |
|
||||
| 16 | | | |
|
||||
| 17 | | | |
|
||||
| 18 | | | |
|
||||
| 19 | | | |
|
||||
| 20 | | | |
|
||||
| 21 | | | |
|
||||
| 22 | | | |
|
||||
| 23 | | | |
|
||||
| 24 | | | |
|
||||
| 25 | | | |
|
||||
| :--: | :----: | :----: | :------- |
|
||||
| [01] | ✓ | ✓ | [Rust] |
|
||||
| [02] | ✓ | ✓ | [Rust] |
|
||||
| [03] | ✓ | ✓ | [Rust] |
|
||||
| [04] | ✓ | ✓ | [Rust] |
|
||||
| [05] | ✓ | ✓ | [Rust] |
|
||||
| [06] | ✓ | ✓ | [Rust] |
|
||||
| [07] | ✓ | ✓ | [Rust] |
|
||||
| [08] | ✓ | ✓ | [Rust] |
|
||||
| [09] | ✓ | ✓ | [Rust] |
|
||||
| [10] | ✓ | ✓ | [Rust] |
|
||||
| [11] | | | |
|
||||
| [12] | | | |
|
||||
| [13] | | | |
|
||||
| [14] | | | |
|
||||
| [15] | | | |
|
||||
| [16] | | | |
|
||||
| [17] | | | |
|
||||
| [18] | | | |
|
||||
| [19] | | | |
|
||||
| [20] | | | |
|
||||
| [21] | | | |
|
||||
| [22] | | | |
|
||||
| [23] | | | |
|
||||
| [24] | | | |
|
||||
| [25] | | | |
|
||||
|
||||
<!-- links -->
|
||||
|
||||
[rust]: https://www.rust-lang.org
|
||||
[01]: day-01/
|
||||
[02]: day-02/
|
||||
[03]: day-03/
|
||||
[04]: day-04/
|
||||
[05]: day-05/
|
||||
[06]: day-06/
|
||||
[07]: day-07/
|
||||
[08]: day-08/
|
||||
[09]: day-09/
|
||||
[10]: day-10/
|
||||
[11]: day-11/
|
||||
[12]: day-12/
|
||||
[13]: day-13/
|
||||
[14]: day-14/
|
||||
[15]: day-15/
|
||||
[16]: day-16/
|
||||
[17]: day-17/
|
||||
[18]: day-18/
|
||||
[19]: day-19/
|
||||
[20]: day-20/
|
||||
[21]: day-21/
|
||||
[22]: day-22/
|
||||
[23]: day-23/
|
||||
[24]: day-24/
|
||||
[25]: day-25/
|
||||
|
6
2022/day-10/outputs/part_two/puzzle.txt
Normal file
6
2022/day-10/outputs/part_two/puzzle.txt
Normal file
@ -0,0 +1,6 @@
|
||||
###..####.#..#.####..##..###..####.####.
|
||||
#..#.#....#.#.....#.#..#.#..#.#....#....
|
||||
#..#.###..##.....#..#....#..#.###..###..
|
||||
###..#....#.#...#...#....###..#....#....
|
||||
#.#..#....#.#..#....#..#.#....#....#....
|
||||
#..#.#....#..#.####..##..#....####.#....
|
6
2022/day-10/outputs/part_two/test.txt
Normal file
6
2022/day-10/outputs/part_two/test.txt
Normal file
@ -0,0 +1,6 @@
|
||||
##..##..##..##..##..##..##..##..##..##..
|
||||
###...###...###...###...###...###...###.
|
||||
####....####....####....####....####....
|
||||
#####.....#####.....#####.....#####.....
|
||||
######......######......######......####
|
||||
#######.......#######.......#######.....
|
@ -15,9 +15,9 @@ fn main() -> io::Result<()> {
|
||||
fn solve(path: &str) -> io::Result<i64> {
|
||||
let instructions = parse_input(path)?;
|
||||
|
||||
let mut cycles_total = 0;
|
||||
let mut reg_x = 1;
|
||||
let mut sig_strength_total = 0;
|
||||
let mut cycles_total: i64 = 0;
|
||||
let mut reg_x: i64 = 1;
|
||||
let mut sig_strength_total: i64 = 0;
|
||||
|
||||
for instruction in instructions {
|
||||
let (cycles, add_x) = match instruction {
|
||||
|
@ -22,8 +22,8 @@ fn solve(path: &str) -> io::Result<String> {
|
||||
let mut crt = Vec::<[char; 40]>::new();
|
||||
let mut crt_row = [PIXEL_UNLIT; 40];
|
||||
|
||||
let mut cycles_total = 0;
|
||||
let mut reg_x = 1_i64;
|
||||
let mut cycles_total: i64 = 0;
|
||||
let mut reg_x: i64 = 1;
|
||||
|
||||
for instruction in instructions {
|
||||
let (cycles, add_x) = match instruction {
|
||||
@ -34,7 +34,7 @@ fn solve(path: &str) -> io::Result<String> {
|
||||
for _ in 0..cycles {
|
||||
let cur_row_pos = cycles_total % DRAW_CYCLE;
|
||||
|
||||
if (reg_x - 1..=reg_x + 1).contains(&cur_row_pos) {
|
||||
if ((reg_x - 1)..=(reg_x + 1)).contains(&cur_row_pos) {
|
||||
crt_row[cur_row_pos as usize] = PIXEL_LIT;
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ fn solve(path: &str) -> io::Result<String> {
|
||||
let lines = crt
|
||||
.iter()
|
||||
.map(|elem| elem.iter().collect::<String>())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
.reduce(|acc, elem| acc + "\n" + &elem)
|
||||
.unwrap();
|
||||
|
||||
Ok(lines)
|
||||
}
|
||||
@ -64,28 +64,14 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn sample() {
|
||||
const OUTPUT: &str = "\
|
||||
##..##..##..##..##..##..##..##..##..##..
|
||||
###...###...###...###...###...###...###.
|
||||
####....####....####....####....####....
|
||||
#####.....#####.....#####.....#####.....
|
||||
######......######......######......####
|
||||
#######.......#######.......#######.....";
|
||||
|
||||
const OUTPUT: &str = include_str!("../../outputs/part_two/test.txt");
|
||||
let result = solve("inputs/test.txt").unwrap();
|
||||
assert_eq!(OUTPUT, &result)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn puzzle() {
|
||||
const OUTPUT: &str = "\
|
||||
###..####.#..#.####..##..###..####.####.
|
||||
#..#.#....#.#.....#.#..#.#..#.#....#....
|
||||
#..#.###..##.....#..#....#..#.###..###..
|
||||
###..#....#.#...#...#....###..#....#....
|
||||
#.#..#....#.#..#....#..#.#....#....#....
|
||||
#..#.#....#..#.####..##..#....####.#....";
|
||||
|
||||
const OUTPUT: &str = include_str!("../../outputs/part_two/puzzle.txt");
|
||||
let result = solve("inputs/puzzle.txt").unwrap();
|
||||
assert_eq!(OUTPUT, result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user