package Ġcom . a oc . panel Ċ Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġcom . a oc . Day Ċ import Ġcom . a oc . input . Input Reader Ċ import Ġorg . junit . jupiter . api . DisplayName Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert Throws Ċ Ċ class ĠPanel Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġwire Strings Ġ= ĠInput Reader . read < String >( Day ( 3 )). value ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given Ġthe Ġwire s Ġfrom Ġthe Ġbasic Ġexample , Ġwhen Ġcalculating Ġthe Ġclosest Ġintersection Ġpoint , Ġthen Ġit Ġshould Ġreturn Ġ 6 ") ĊĠĠĠ Ġfun Ġbasic Example () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( Wire (" R 8 , U 5 , L 5 , D 3 "), ĠWire (" U 7 , R 6 , D 4 , L 4 ")) ĊĠĠĠĠĠĠĠ Ġval Ġdistance Ġ= Ġpanel . find Intersection Point Closest To Central Port () ĊĠĠĠĠĠĠĠ ĠassertThat ( distance ). isEqualTo ( 6 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given Ġthe Ġwire s Ġfrom Ġexample Ġone , Ġwhen Ġcalculating Ġthe Ġclosest Ġintersection Ġpoint , Ġthen Ġit Ġshould Ġreturn Ġ 1 5 9 ") ĊĠĠĠ Ġfun Ġexample One () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfirst Wire Ġ= ĠWire (" R 7 5 , D 3 0 , R 8 3 , U 8 3 , L 1 2 , D 4 9 , R 7 1 , U 7 , L 7 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecond Wire Ġ= ĠWire (" U 6 2 , R 6 6 , U 5 5 , R 3 4 , D 7 1 , R 5 5 , D 5 8 , R 8 3 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( first Wire , Ġsecond Wire ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( panel . find Intersection Point Closest To Central Port ()). isEqualTo ( 1 5 9 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given Ġthe Ġwire s Ġfrom Ġexample Ġtwo , Ġwhen Ġcalculating Ġthe Ġclosest Ġintersection Ġpoint , Ġthen Ġit Ġshould Ġreturn Ġ 1 3 5 ") ĊĠĠĠ Ġfun Ġexample Two () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfirst Wire Ġ= ĠWire (" R 9 8 , U 4 7 , R 2 6 , D 6 3 , R 3 3 , U 8 7 , L 6 2 , D 2 0 , R 3 3 , U 5 3 , R 5 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecond Wire Ġ= ĠWire (" U 9 8 , R 9 1 , D 2 0 , R 1 6 , D 6 7 , R 4 0 , U 7 , R 1 5 , U 6 , R 7 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( first Wire , Ġsecond Wire ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( panel . find Intersection Point Closest To Central Port ()). isEqualTo ( 1 3 5 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given ĠDay Ġ 3 Ġpuzzle Ġinput , Ġwhen Ġcalculating Ġthe Ġman h att an Ġdistance , Ġthen Ġit Ġshould Ġreturn Ġ 5 2 9 ") ĊĠĠĠ Ġinternal Ġfun Ġsolution Part One () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( Wire ( wire Strings [ 0 ]), ĠWire ( wire Strings [ 1 ])) ĊĠĠĠĠĠĠĠ Ġval Ġdistance Ġ= Ġpanel . find Intersection Point Closest To Central Port () ĊĠĠĠĠĠĠĠ ĠassertThat ( distance ). isEqualTo ( 5 2 9 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given ĠDay Ġ 3 ĠPart Ġ 2 Ġexample Ġone Ġpuzzle Ġinput , Ġwhen Ġcalculating Ġthe Ġfew est Ġcombined Ġsteps Ġto Ġintersection , Ġit Ġshould Ġreturn Ġ 6 1 0 ") ĊĠĠĠ Ġfun Ġpart Two Example One () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfirst Wire Ġ= ĠWire (" R 7 5 , D 3 0 , R 8 3 , U 8 3 , L 1 2 , D 4 9 , R 7 1 , U 7 , L 7 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecond Wire Ġ= ĠWire (" U 6 2 , R 6 6 , U 5 5 , R 3 4 , D 7 1 , R 5 5 , D 5 8 , R 8 3 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( first Wire , Ġsecond Wire ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( panel . find Short est Combined Intersection Paths ()). isEqualTo ( 6 1 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given ĠDay Ġ 3 ĠPart Ġ 2 Ġexample Ġtwo Ġpuzzle Ġinput , Ġwhen Ġcalculating Ġthe Ġfew est Ġcombined Ġsteps Ġto Ġintersection , Ġit Ġshould Ġreturn Ġ 4 1 0 ") ĊĠĠĠ Ġfun Ġpart Two Example Two () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfirst Wire Ġ= ĠWire (" R 9 8 , U 4 7 , R 2 6 , D 6 3 , R 3 3 , U 8 7 , L 6 2 , D 2 0 , R 3 3 , U 5 3 , R 5 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecond Wire Ġ= ĠWire (" U 9 8 , R 9 1 , D 2 0 , R 1 6 , D 6 7 , R 4 0 , U 7 , R 1 5 , U 6 , R 7 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( first Wire , Ġsecond Wire ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( panel . find Short est Combined Intersection Paths ()). isEqualTo ( 4 1 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given ĠDay Ġ 3 Ġpuzzle Ġinput , Ġwhen Ġcalculating Ġthe Ġshortest Ġcombined Ġintersection Ġdistance , Ġthen Ġit Ġshould Ġreturn Ġ 2 0 3 8 6 ") ĊĠĠĠ Ġfun Ġsolution Part Two () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( Wire ( wire Strings [ 0 ]), ĠWire ( wire Strings [ 1 ])) ĊĠĠĠĠĠĠĠ Ġval Ġdistance Ġ= Ġpanel . find Short est Combined Intersection Paths () ĊĠĠĠĠĠĠĠ ĠassertThat ( distance ). isEqualTo ( 2 0 3 8 6 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Given Ġtwo Ġwire s Ġwith Ġno Ġinter sections , Ġwhen Ġfinding Ġthe Ġshortest Ġcombined Ġintersection Ġpaths , Ġthen " Ġ+ ĊĠĠĠ Ġ" it Ġshould Ġthrow Ġan Ġexception ") ĊĠĠĠ Ġfun Ġno Inter sections Should Throw Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpanel Ġ= ĠPanel ( Wire (" D 1 "), ĠWire (" U 5 ")) ĊĠĠĠĠĠĠĠ Ġval Ġe Ġ= ĠassertThrows < IllegalStateException > Ġ{ Ġpanel . find Short est Combined Intersection Paths () Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( e . message ). isEqualTo (" No ĠInter sections ĠFound ") ĊĠĠĠ Ġ} Ċ }