We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c12bf18 commit e6134e2Copy full SHA for e6134e2
retos/reto-6/main.ts
@@ -0,0 +1,15 @@
1
+function maxDistance(movements) {
2
+ let distance = 0
3
+
4
+ let right = movements.match(/>/g)?.length ?? 0
5
+ let left = movements.match(/</g)?.length ?? 0
6
7
+ distance += right
8
+ distance -= left
9
10
+ let extra = movements.length - (right + left)
11
12
+ return Math.abs(distance) + Math.abs(extra)
13
+}
14
15
+module.exports = maxDistance
0 commit comments