tangled
alpha
login
or
join now
baileytownsend.dev
/
at-advent
forked from
oppi.li/at-advent
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
pipelines
wire in the day3 check
bad-example.com
1 week ago
98ffafdd
87f9a7d0
+28
-3
1 changed file
expand all
collapse all
unified
split
shared
src
advent
challenges
day_three
day_three.rs
+28
-3
shared/src/advent/challenges/day_three/day_three.rs
···
70
70
71
71
async fn check_part_one(
72
72
&self,
73
73
-
_did: String,
74
74
-
_verification_code: Option<String>,
73
73
+
did: String,
74
74
+
verification_code: Option<String>,
75
75
) -> Result<ChallengeCheckResponse, AdventError> {
76
76
-
todo!()
76
76
+
let Some(submitted_code) = verification_code else {
77
77
+
return Ok(ChallengeCheckResponse::Incorrect(
78
78
+
"No code was submitted!".to_string(),
79
79
+
));
80
80
+
};
81
81
+
82
82
+
let Some(progress) = self.get_days_challenge(&did).await? else {
83
83
+
return Err(AdventError::ShouldNotHappen(
84
84
+
"Challenge not started".to_string(),
85
85
+
));
86
86
+
};
87
87
+
88
88
+
let Some(expected) = progress.verification_code_one else {
89
89
+
return Err(AdventError::ShouldNotHappen(
90
90
+
"No verification code found".to_string(),
91
91
+
));
92
92
+
};
93
93
+
94
94
+
if submitted_code.trim().eq_ignore_ascii_case(&expected) {
95
95
+
Ok(ChallengeCheckResponse::Correct)
96
96
+
} else {
97
97
+
Ok(ChallengeCheckResponse::Incorrect(
98
98
+
"That's not the right code. Try inspecting the record data inside the CAR file.".into()
99
99
+
))
100
100
+
}
77
101
}
102
102
+
78
103
}