Skip to content

Commit

Permalink
reto-6
Browse files Browse the repository at this point in the history
  • Loading branch information
fernargdev committed Dec 15, 2023
1 parent 1ac96d5 commit e06b789
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion retos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<!-- <script src="reto-2.js"></script> -->
<!-- <script src="reto-3.js"></script> -->
<!-- <script src="reto-4.js"></script> -->
<script src="reto-5.js"></script>
<!-- <script src="reto-5.js"></script> -->
<!-- <script src="reto-6.js"></script> -->
</body>

</html>
13 changes: 13 additions & 0 deletions retos/reto-6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable no-unused-vars */
/* eslint-disable space-before-function-paren */
function maxDistance(movements: string) {
let distance = 0
let right = movements.match(/>/g)?.length ?? 0
let left = movements.match(/</g)?.length ?? 0
let extra = movements.length - (right + left)

distance += right
distance -= left

return Math.abs(distance) + extra
}

0 comments on commit e06b789

Please sign in to comment.