completed 5 p2

This commit is contained in:
mtrx 2024-12-07 01:29:29 +01:00
parent 699d209501
commit 4462c12f77

View file

@ -47,8 +47,8 @@ class DayFive implements Solvable {
const [compliant, leftIdx, rightIdx] = this.followsRules(update)
if (!compliant) {
// remove offending item and just move it to the back
const removedLeft = update.splice(leftIdx, 1)
const rebuiltUpdate = [...update.slice(0, rightIdx), removedLeft[0], ...update.slice(rightIdx, -1)]
const removedLeft = update.splice(leftIdx, 1)[0]
const rebuiltUpdate = [...update.slice(0, rightIdx), removedLeft, ...update.slice(rightIdx)]
return sort(rebuiltUpdate)
} else {
return update