Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa83c0b

Browse files
test(20190-day-03): specs for finding closest wire intersection by wire distance
1 parent5df7932 commitaa83c0b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎2019/day-03/wires.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,37 @@ describe('--- 2019 Day 3: Crossed Wires ---', () => {
5555
expect(getClosesetIntersection(findWireIntersections(wires)).distance).to.equal(distances[idx])
5656
})
5757
})
58+
describe('getIntersectionWireDistance()',()=>{
59+
it('calculates the summed total wire length to reach the specified intersection',()=>{
60+
constwires=[
61+
'R8,U5,L5,D3',
62+
'U7,R6,D4,L4'
63+
]
64+
constexpected=[
65+
40,30
66+
]
67+
constintersections=findWireIntersections(...wires)
68+
constactual=intersections.map((inter)=>getIntersectionWireDistance({wires,intersection:inter}))
69+
expect(actual).to.deep.equal(expected)
70+
})
71+
})
72+
describe('getClosestIntersectionByWire()',()=>{
73+
it('can be used to find the wire distance to the closest intersection',()=>{
74+
constwiresets=[
75+
[
76+
'R75,D30,R83,U83,L12,D49,R71,U7,L72',
77+
'U62,R66,U55,R34,D71,R55,D58,R83'
78+
],[
79+
'R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51',
80+
'U98,R91,D20,R16,D67,R40,U7,R15,U6,R7'
81+
]
82+
]
83+
constdistances=[610,410]
84+
wiresets.forEach((wires,idx)=>{
85+
constintersections=findWireIntersections(wires)
86+
expect(getClosesetIntersectionByWire({ intersections, wires}).distance).to.equal(distances[idx])
87+
})
88+
})
89+
})
5890
})
5991
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp