File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ versión estaré usando TypeScript, en su versión 5.3.2.
18
18
| 03 | [ ** El elfo travieso** ] ( https://adventjs.dev/es/challenges/2023/3 ) | 🟢 | [ 03 TS] ( ./src/challenges/03.ts ) |
19
19
| 04 | [ ** Dale vuelta a los parentesis** ] ( https://adventjs.dev/es/challenges/2023/4 ) | 🟠 | [ 04 TS] ( ./src/challenges/04.ts ) |
20
20
| 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 ) |
21
22
22
23
## Herramientas
23
24
@@ -55,7 +56,8 @@ Este comando los listará todos pero solo ejecutará el que se le indique.
55
56
56
57
## Estado de las pruebas (instalación de dependencias, lint, tests)
57
58
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 )
59
61
60
62
## Copyrigth
61
63
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ } )
You can’t perform that action at this time.
0 commit comments