aboutsummaryrefslogtreecommitdiff
path: root/2023/day-01
diff options
context:
space:
mode:
Diffstat (limited to '2023/day-01')
-rw-r--r--2023/day-01/src/bin/part2.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/2023/day-01/src/bin/part2.rs b/2023/day-01/src/bin/part2.rs
index 5185b76..99f8748 100644
--- a/2023/day-01/src/bin/part2.rs
+++ b/2023/day-01/src/bin/part2.rs
@@ -19,18 +19,6 @@ fn find_min<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) {
(*position, word)
}
-#[test]
-fn test_find_min_1() {
- let input = vec!((1, "eight"), (2, "eight"), (3, "2"));
- assert_eq!(find_min(&input), (1, "eight"));
-}
-
-#[test]
-fn test_find_min_2() {
- let input = vec!((4, "eight"), (5, "eight"), (3, "2"));
- assert_eq!(find_min(&input), (3, "2"));
-}
-
fn find_max<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) {
let (position, word) = matches.iter().min_by(|(x,_), (y, _)| {
y.cmp(x)
@@ -58,6 +46,19 @@ fn process_line(s: &str) -> i32 {
(mapping[min_number] * 10) + mapping[max_number]
}
+
+#[test]
+fn test_find_min_1() {
+ let input = vec!((1, "eight"), (2, "eight"), (3, "2"));
+ assert_eq!(find_min(&input), (1, "eight"));
+}
+
+#[test]
+fn test_find_min_2() {
+ let input = vec!((4, "eight"), (5, "eight"), (3, "2"));
+ assert_eq!(find_min(&input), (3, "2"));
+}
+
#[test]
fn simple_input() {
let string = "onetwo";