mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-12-22 14:05:48 +00:00
Improve Day 22 Task 1
This commit is contained in:
parent
a1d50f0948
commit
db833507ef
|
@ -7,17 +7,11 @@ pub(crate) fn router() -> Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn integers(nums: String) -> Result<impl IntoResponse, StatusCode> {
|
async fn integers(nums: String) -> Result<impl IntoResponse, StatusCode> {
|
||||||
let mut nums = nums
|
nums.lines()
|
||||||
.lines()
|
.map(|s| s.parse::<u64>())
|
||||||
.map(|s| s.parse::<u64>().expect("All lines should be valid u64s"))
|
.try_fold(0u64, |acc, n| n.map(|n| acc ^ n))
|
||||||
.collect::<Vec<_>>();
|
.map(|n| "🎁".repeat(n as usize))
|
||||||
nums.sort_unstable();
|
.map_err(|_| StatusCode::BAD_REQUEST)
|
||||||
for i in (0..nums.len()).step_by(2) {
|
|
||||||
if i == (nums.len() - 1) || nums[i] != nums[i + 1] {
|
|
||||||
return Ok("🎁".repeat(nums[i] as usize));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(StatusCode::BAD_REQUEST)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn rocket(input: String) -> Result<impl IntoResponse, StatusCode> {
|
async fn rocket(input: String) -> Result<impl IntoResponse, StatusCode> {
|
||||||
|
|
Loading…
Reference in a new issue