Skip to content

Commit

Permalink
feat(2023): update solution for challenge #06
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 6, 2023
1 parent 20440ba commit 3a236a6
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions 2023/challenge-06/challenge-06.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ export function maxDistance(movements: string) {
let maxRight = 0

for (const movement of movements) {
if (movement === '>') {
maxRight++
maxLeft--
} else if (movement === '<') {
maxLeft++
maxRight--
} else {
maxLeft++
maxRight++
}
const rightPoint = +(movement === '>')
const leftPoint = +(movement === '<')
const extraPoint = +(movement === '*')

maxRight += rightPoint - leftPoint + extraPoint
maxLeft += leftPoint - rightPoint + extraPoint
}

return Math.max(maxLeft, maxRight)
Expand Down

0 comments on commit 3a236a6

Please sign in to comment.