Skip to content

Commit 50c9bc6

Browse files
committed
🎁 added challenge 6
1 parent f3c10ba commit 50c9bc6

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

readme.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ versión estaré usando TypeScript, en su versión 5.3.2.
1818
| 03 | [**El elfo travieso**](https://adventjs.dev/es/challenges/2023/3) | 🟢 | [03 TS](./src/challenges/03.ts) |
1919
| 04 | [**Dale vuelta a los parentesis**](https://adventjs.dev/es/challenges/2023/4) | 🟠 | [04 TS](./src/challenges/04.ts) |
2020
| 05 | [**El CyberTruck de Santa**](https://adventjs.dev/es/challenges/2023/5) | 🟠 | [05 TS](./src/challenges/05.ts) |
21+
| 06 | [**Los renos a prueba**](https://adventjs.dev/es/challenges/2023/6) | 🟢 | [06 TS](./src/challenges/06.ts) |
2122

2223
## Herramientas
2324

@@ -55,7 +56,8 @@ Este comando los listará todos pero solo ejecutará el que se le indique.
5556

5657
## Estado de las pruebas (instalación de dependencias, lint, tests)
5758

58-
[![pnpm ci - eslint - tests](https://github.com/jamerrq/advent-js-2023/actions/workflows/ci-eslint-tests.yml/badge.svg)](https://github.com/jamerrq/advent-js-2023/actions/workflows/ci-eslint-tests.yml)
59+
[![pnpm ci - eslint -
60+
tests](https://github.com/jamerrq/advent-js-2023/actions/workflows/ci-eslint-tests.yml/badge.svg)](https://github.com/jamerrq/advent-js-2023/actions/workflows/ci-eslint-tests.yml)
5961

6062
## Copyrigth
6163

src/challenges/06.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function maxDistance (movements: string): number {
2+
// Code here
3+
const left = [...movements].filter((char) => char === '>').length
4+
const right = [...movements].filter((char) => char === '<').length
5+
const stars = movements.length - left - right
6+
return Math.max(left, right) + stars - Math.min(left, right)
7+
}

src/tests/06.spec.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { test, expectTypeOf, expect, describe } from 'vitest'
2+
import { maxDistance } from '../challenges/06'
3+
4+
describe('Challenge #06', () => {
5+
test('Test #01', () => {
6+
expectTypeOf(maxDistance).returns.toEqualTypeOf(0)
7+
})
8+
9+
test('Test #02', () => {
10+
expect(maxDistance('>>*<')).toEqual(2)
11+
})
12+
13+
test('Test #03', () => {
14+
expect(maxDistance('<<<<<')).toEqual(5)
15+
})
16+
17+
test('Test #04', () => {
18+
expect(maxDistance('>***>')).toEqual(5)
19+
})
20+
21+
test('Test #05', () => {
22+
expect(maxDistance('**********')).toEqual(10)
23+
})
24+
25+
test('Test #06', () => {
26+
expect(maxDistance('<<**>>')).toEqual(2)
27+
})
28+
})

0 commit comments

Comments
 (0)