Skip to content

Commit 3ba8b59

Browse files
committed
2023 21 (uiua) part 1
1 parent c078b34 commit 3ba8b59

File tree

4 files changed

+234
-0
lines changed

4 files changed

+234
-0
lines changed

2023/src/bin/day-21/example_1

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
...........
2+
.....###.#.
3+
.###.##..#.
4+
..#.#...#..
5+
....#.#....
6+
.##..S####.
7+
.##..#...#.
8+
.......##..
9+
.##.#.####.
10+
.##..##.##.
11+
...........

2023/src/bin/day-21/input

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
...................................................................................................................................
2+
.#.###.......#.##...........................#...#....#.#.#.#...........#.......##....#.#.........#....#....#.........##.##.....#...
3+
.#.......#.......#.....#...............#..#.#.#....#......#..............###.....#...........#...#......##..............#......#.#.
4+
................#....................#.......#...#......................#..................#...#.........#.......###...........##..
5+
..#..###...........#.##....#..........#...........##..#.#............................#........#..#.#.#..#....#..#...#...##......##.
6+
..........#.....##....#........#......#........#...#..#.............................#........#.#.....#....#..#.#....#...#......#.#.
7+
....#..........##.....#...........#..........#....................#...........#.........#.....#.#...#..##.........#.......#........
8+
.......#.#..#.####....................#.#...#.....#.................#...........#....#...........#....##......#....................
9+
..##......#.#..#.#...#..............#.........#....#................#........#.#...#.........#..................#........#.#..#....
10+
....#.#.#.........#..#..............#.#......#................................#......#.....#....##.............##..#....#....#...#.
11+
..#.................#.#.#.......#...#........#................#.#...............................#..#.#.......#.......#.......#.....
12+
.#...#.#.#....................#..#......#...#.#...........#....##.......#.......#...........#............#.#.##......#..#..........
13+
..#.....##............#..#...#..........#..#...#.........#...#........#............##...#....#...........#..#......#.....#.##.#....
14+
...............#.#..#.#.....#......##.#.......##..............##..........................#........#.....#.#....#.....#.....#......
15+
...........#...#.#....#.....#........##..................#..#......#.##....#........#.#..#.#...............#.#.........#.....#.....
16+
..............##.....#..#.......#.........#..............##........................................#..#...##....#.........#.#......
17+
.#.........#.#.......##......#...#...#...............##....##......####...#..................#............##.......#..#.##..#......
18+
......#.......#............##.#....#......................#.............#...#.#.........##................#.#.............#...#.#..
19+
........#.#........##............#...#...............#.#....##..............#...............#.................#.#..#.#.....#.#...#.
20+
...#......#....#....#....#..#......#....................##..#............#..#...........#.......................#......##......#...
21+
.............##.....#..#.##............#.............##......#......#..#..#..#...............#.............#..#.......##...........
22+
............##.#...#..........................................#............#.................##.......##....#.........#..#.#.......
23+
...##.#.##..#......#.......##......#.#............#.#.....#............#.##...................#.............#..###..#.#....#....##.
24+
......#......#................##....##.................#..#.#.#.#....#.......#...............#...............#..........#...##.....
25+
....#.................#..........##..........##....#..#........#.........##.#.....................###......#..............#..#.....
26+
.###.............#.#........................................#.#.#..#...#.......................#.###...........###....#.......#..#.
27+
..#...#..#........#...#.........#...........#....#....#.#...#.#....#...#.#...........................###.....#....#...#.....#......
28+
..#.......##.....#.#...#.......#..........#.#.......#...#..#.#.........#.............#.............#.....##..##.........#..........
29+
..........#......#..#.....#..............#..#...#.#.#...#.#...#...#...#..............................##..#...####.##...##..........
30+
.....#..............#..........##............#.#..#.......#.#...#...##.##....#.......##...#............#.#............#.....#....#.
31+
.#........#..............#..............#..###....#...#......#..........#.............#..............#...#...#.#........#..........
32+
...............#.#....#...................#........##..#..##..............#.#..............................###....#.....#....#.....
33+
......#.#.........#.......#...............#....#.#..#..###.#.........#..#...#......#..#..#...........#.......##......#..#......#...
34+
.#..................##..#...........#.##.....#....#....................#.....#........###..............#.....##.....##....#..#.....
35+
.#...#..#..............#.#.........#............#....#....##..........##..#.......#.####....##.#.....................#.............
36+
......#............#....##...........#...........##........#...#...#.....................###.#...........#.............#........#..
37+
...................##.............................#.#....#...#.....#..#......#............#.................#......#.....#.#.#.....
38+
...........#..#........#..........##....#.........##..#........#...#.#..#...#.............#....#.............#.#..#...........#.##.
39+
...#.........##......................#.#..........##...#.#..##......#...#...................#.#.#...............###............#.#.
40+
.....#..#......................#.#.................#..#.........#.#.........#...#...#..##...#.....#.#..................#...........
41+
.#..............................#......#..............####...........#...#.#........##.............................##....#.........
42+
...................#.........#.....#......#.#.................#.#...#..#............#......#........##..............#.#.#..........
43+
.......#.#.#...............#.#..#..##..............#..#.#...##.........#.#......##.....................#.......#.............#.....
44+
..#...#.#...#......................#....#...##..#.......##...#.........#......###...##...#...........................#.............
45+
................#..............##............#.......#..........#.......#..........#..................#..............#...#.........
46+
...#.#.........#....................#................#..........#....#...#..#.......##..#....#..##.........................##......
47+
.#..#....##.................#..........#...#.....#....#.......#.#..#......#...#.................#.......###..........#.....#..#.#..
48+
....#....#............#....#.#...##.###..........#.......#...##.#...#...................##......#..#......#...............#........
49+
.........#...................#........#....#...#....##......#.....#.#..#.#......#..#.##....#.....#.....#.....#..................##.
50+
.....................#.....#...............###.................#......#...###.##.........#..#....#......#.............#....###..#..
51+
......................#......#..#.......#...#...###..#........##..........#...#...........#.....##.........#.#.#...................
52+
..#..................#............#.#..#....#.#...............#..............##.....#..#......#.#..##.......#..............##......
53+
............................#.........#.....#.#..........#.............###.....#..##...#.#...#...#....#.....#...............#......
54+
......#.....................#....#...#............#.....#..............##........#......#.#.......###.......#...#.........#..#.....
55+
.......#.........#.#..#........##.#....#...#...#...#.......#....#........#...###.##..#.......#......#......................#.......
56+
...#............##.....#..#.......#......#...#...#.......#..#..#......#....#.....#.................#...#.......#.............#.....
57+
..##.................#...#.#...............###..###.....#...#........#......#.........#.#..##.#...#....#....#.......#..............
58+
....#...........##.................#..........................#.....#...............#.............#.......#........#...............
59+
...........#.....#......#........#.......#.......#......#..............................#..#...#.....#..........................#...
60+
..#............#.#.....##......#.#...###.#.....#.##....#.......................#........##............#.......#.#.#................
61+
...........#...........#.......#......#.....#.##.#.........#............#......#...#..#.#.........###..#...#.#.#.......#...........
62+
.........##.....#..........#..........#.........#..........#...#..........#...............#...........#.#.......#..................
63+
.........#.....#.............#.............#.#.#...#.##.......#.#...#....#.#............#.........#.#...........##.....#...........
64+
..........#.....................##....#.....#...#.#..#.#.............#..#.#......#..............##....#...............#............
65+
..........#.#...#..#..............#....##.....#....#.#.......#..#.#.............#...........#.......#..........#......#..#...#.....
66+
.................................................................S.................................................................
67+
..........###....................................#.......###........#........#....#.................###........#...................
68+
......##......#...#....#.....#...#....#..#...#.....#...#..............#.......#.#.#.#...###.#......#..#..#....#.......#..#.........
69+
..........#...#...........#.#.#.##.#...................#..........####.......#.###.#.......#.....#.###....#...#..#.##......#.......
70+
...........#................#....#....#.......#.................#.......#...#............#...#..............#..##..................
71+
..................#.............................##...#...##..#...........#.........#.#....#...........#.....#..........#.#.........
72+
................#.......#.#...##.###.....#....#...#.........#.#...........#.#.......##.#...#....#.......#..#.##....#...#...........
73+
..............##..#.#....#...#..............##.......#....................#....#....#.#.##....#.......#..#..#......#..#..........#.
74+
....#..............##..#.#...##.....#............##.#...#..#..........#.#...###................#.......#..##..#....................
75+
...............#..#.........................#...............#......#...#.................#..#.....#....#.#.##..#................#..
76+
....#................#..#.........#....#..#....#..........#.#.....##............###........##..........#.....#.................#...
77+
...#......................#.......#....#..............#.........#..........#...#....#...............##..#...................#..#...
78+
.#...#...................#....#........#...#......##....##..#...#............#...#.#.#......#.#..#......##.................#...#...
79+
...#..................#......#...#.#......#......#..###..##.#.....#...#..##.................#.#.#.##.......##....#..........#......
80+
.........##..............#.................##...............#..#......#.#.......#..#....................#.....#....................
81+
.....#....#............#......##...#.......##.....#...............#....#..#...#.............#................#................#.##.
82+
........................##.....#.....#....................#.......#...............#....#.#..#....#.....#......................###..
83+
.....#................#...#......#...#...............#..#...#.....#..............#..#.........#....#.....#..#............#......#..
84+
........#..............#...........###.......................#.#...##.#..##........#....#.#....#......#...#..........#.............
85+
......#.......#.............#..........#..........#.#.#.#...#.................#.......####.........................#....###.#......
86+
....#...#...#.#..........#.......#.......#...#..##.#.###....###.......#...................................#..........#..#..#...#...
87+
.#.......#....###...............#.............#....#..##..........#...........#...#.....##....#..#.................................
88+
..#............#.#.........#....##.#.........#....#....#...#.#.#..#......#...##......#..........##.#...#............#....#.##.##.#.
89+
......#........#..............##.##......#..........##.##.....##......#..#........................#..#.........##..#........#......
90+
..................................##.....#.....#.......#....#.....#..........................###.#.#...........##........#.#.......
91+
.#.......#........#...........#...........#.........#...........#...#.......#...#.#.......##.......................................
92+
.##.#.......#........#.........#...#............#...........#.......#.#........#..#....#.......#...............#..........#..#.....
93+
......#....#.......#...........#......#.................#...........##.......#...#.........#.#.##..#........#....#.......#..#......
94+
.#........##.....##...............#......#....#..#..#..#.#...#....#............#.....#.............................#.........#.....
95+
..#...#..........#................#.....#..#...#....................#.#..#............#.....#..##...........###..................#.
96+
..........#..#..#........................#..#..#.........##.........#.......#......#.........#...............#...#......##.....#...
97+
...#.....#...##........#....................................#..........#...#.......#..#....#.#..........#.#.#...#............#..#..
98+
.....#........#.....#....................#........#....#...........#....#...#................#....................#........##......
99+
.......#.#.#.......#.......##..........#...#..#..#......#...#.......##...##.....##.#.................#.........##...##.............
100+
.............#..#.....#.#....##........#.....#.......#....#............##...#..#........................#......#......#......#.....
101+
...#.....#......#.......#.#.............#...............#.....##.........#..#.........#.............#..#...#...#..........#...#....
102+
........#.......................#........#.#.......##..#.##...###..#..#....#.#.....##........................#...................#.
103+
............#..#.#.#......#...........................#.............#.#.......#..#..................#..........#..............#....
104+
.#.....#..#..##..##............##.#........##..#..#...................#.......#...................#.......#.......##.#.............
105+
.#.#..#...#.#.........#.#..#......#.........#.#..............#.#....#..#.....#....#.#.....................##........#..#....#....#.
106+
..#....#.#........#..........#...#..#.....................#...#........#.....###.....................#.#..#..#..#...#.#..#.........
107+
.#.......#..#....#...............#..#...............#......#................#................#......###....#.................#.....
108+
....#.#..#...#..#....#..#..#...........................#..#...#.#.#................#..................#........#.......#.......#.#.
109+
........#.........................#...#............#......#.#...........#.....#....#.......#.#.#...#....#.......#...#.....##.......
110+
......#...#....#.......#.....##.#...............#................................#.........##.##......#.#.....#................#...
111+
..#..#....#.#.#.......#......#.........#............#..........#............#..............#..#...#.#...##..#...#........#.#.#.....
112+
..#.......#.....##......#........#....##..........................##...#.#.#.................................#.#.......#..##.......
113+
....#..#...##............#....##...#......#.........................#......#.##.........##..........#..............##...#..........
114+
...#...#...#........#..#......#...#.....#......................#.........#..#..........#.........##.........##.....................
115+
.......#.............#.......#.......#....#.#........#.....#.#..#.#....................#..........#.#.....#.#.......#..#...........
116+
.#............#..###..........#..............................#......##...................##............##...#.#......#...........#.
117+
...#........................#..........##..#.......................#......#.........###...................#..#...................#.
118+
.#......................#..##.#....#...........#..........#.......................#...#..#.....##....#.##......#...................
119+
.#.........#.....#...#......##..#...#....#..#......................#.................#.#.............#.....#.....##......#.........
120+
....#.........#........#.#.....#....#...#....#....................#.....#.......#........#.....#.....#.#..........#.......#......#.
121+
...#..#........#......##.......................#.............#......##.........#.....#...#.#...#.#...........#.......##........#...
122+
.......#.........##.....#.#.............#...#......#........#..#......#.........#............#.#.......#.#............#..##.#......
123+
........#..#......#.#..#...#.....#..............................................##..#..#.....##..#......#..#.#...#.........#....#..
124+
.#.#...#.....#.#................##..#.........#.#.##..#..........................#..#..........#.....##.###.#.........#....#.......
125+
........#.#..............#......#....#..........#.....##....................#....#..........#.............#..#....#..........#.....
126+
.......#...................##...#.#...#...#.#...###.##.##.........#............#.#.#..................#...#.#..##......#...#.......
127+
....#.....#....###.....###........#......#.....#.....#..............................#..#........#....##........#...#..........#....
128+
..###.#..#........#.....#...#.#.#.#....##.....#.#.........................#.##..#...#.....................##.....#........#.....##.
129+
..#.#.#.##...#.#....#.##...#.......#.#......#.##.........#.............#.#.....#...........#.....##..........#........#....#.......
130+
......##................#.#.......#............#..#......##.#.......................#........#.#.#...#.....#.........#...#.#.......
131+
...................................................................................................................................

2023/src/bin/day-21/main.rs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#![allow(dead_code, unreachable_code, unused_imports, unused_variables)]
2+
3+
use itertools::Itertools;
4+
use std::fs;
5+
6+
fn main() {
7+
println!("Part 1: {}", solve_part_1(include_str!("example_1")));
8+
// println!("Part 1: {}", solve_part_1(include_str!("../input")));
9+
10+
// println!("Part 2: {}", solve_part_2(include_str!("../example_1")));
11+
// println!("Part 2: {}", solve_part_2(include_str!("../input")));
12+
}
13+
14+
fn solve_part_1(input: &str) -> i32 {
15+
0
16+
}
17+
18+
fn solve_part_2(input: &str) -> i32 {
19+
0
20+
}
21+
22+
#[cfg(test)]
23+
mod tests {
24+
use super::*;
25+
use pretty_assertions::assert_eq;
26+
27+
#[test]
28+
fn part_1_examples() {
29+
assert_eq!(solve_part_1(include_str!("example_1")), todo!());
30+
}
31+
32+
#[ignore]
33+
#[test]
34+
fn part_1_input() {
35+
assert_eq!(solve_part_1(include_str!("input")), todo!());
36+
}
37+
38+
#[ignore]
39+
#[test]
40+
fn part_2_examples() {
41+
assert_eq!(solve_part_2(include_str!("example_1")), todo!());
42+
}
43+
44+
#[ignore]
45+
#[test]
46+
fn part_2_input() {
47+
assert_eq!(solve_part_2(include_str!("input")), todo!());
48+
}
49+
}

2023/src/bin/day-21/main.ua

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Uiua 0.7.1
2+
3+
Lib ← &i "../../lib.ua"
4+
SplitBy ← Lib "SplitBy"
5+
6+
# SolvePartOne ← |1 0
7+
# ---
8+
# ⍤:≍, x SolvePartOne &fras "example_1"
9+
# ⍤:≍, x SolvePartOne &fras "input"
10+
# ---
11+
12+
# &p $"Part 1: _" SolvePartOne &fras "input"
13+
14+
M ← ⊜∘≠@\n. &fras ("input"|"example_1") 0
15+
S ← ⊢⊚=@S M
16+
17+
# y_x => [y1_x1 y2_x2 ...]
18+
KNbs ← ☇1 +[0_1 1_0 0_¯1 ¯1_0] ¤
19+
20+
# y_x M
21+
KIsWithinRange ← |2 /↧×⊃(≥0|<:⊙⧻)
22+
---
23+
⍤:≍, 1 KIsWithinRange 2_5 ↯ 10_10 0
24+
⍤:≍, 0 KIsWithinRange ¯2_5 ↯ 10_10 0
25+
⍤:≍, 0 KIsWithinRange 2_12 ↯ 10_10 0
26+
---
27+
28+
# y_x M => c
29+
EAtK ← ⊡⊙⊡ ⊃(⊢⇌|⊢)
30+
31+
M
32+
33+
⍥(
34+
☇1≡KNbs # neighbors
35+
▽≡(KIsWithinRange :M) . # within range
36+
≡(EAtK :M) . # chars
37+
▽≠@# # remove rocks
38+
⊏⍏. # sort
39+
⊝ # dedup
40+
)64 S
41+
42+
43+
# 3598, correct

0 commit comments

Comments
 (0)