@@ -18,7 +18,7 @@ impl Solution for Day08 {
1818 let junction_boxes = self . parse ( input) ;
1919 let mut circuits: Vec < Vec < Point3D > > = Vec :: new ( ) ;
2020
21- for pair in self . closest_limited ( & junction_boxes) {
21+ for pair in self . closest ( & junction_boxes) . take ( self . connections ) {
2222 self . assign_pair_to_circuit ( & pair, & mut circuits) ;
2323 }
2424
@@ -36,7 +36,7 @@ impl Solution for Day08 {
3636 let junction_boxes = self . parse ( input) ;
3737 let mut circuits: Vec < Vec < Point3D > > = Vec :: new ( ) ;
3838
39- for pair in self . closest_all ( & junction_boxes) {
39+ for pair in self . closest ( & junction_boxes) {
4040 self . assign_pair_to_circuit ( & pair, & mut circuits) ;
4141
4242 if self . are_all_boxes_connected_in_one_circuit ( & circuits, & junction_boxes) {
@@ -53,11 +53,7 @@ impl Day08 {
5353 input. lines ( ) . map ( |line| line. parse ( ) . unwrap ( ) ) . collect ( )
5454 }
5555
56- fn closest_limited ( & self , boxes : & [ Point3D ] ) -> impl Iterator < Item = Pair > {
57- self . closest_all ( boxes) . take ( self . connections )
58- }
59-
60- fn closest_all ( & self , boxes : & [ Point3D ] ) -> impl Iterator < Item = Pair > {
56+ fn closest ( & self , boxes : & [ Point3D ] ) -> impl Iterator < Item = Pair > {
6157 let mut calculated: Vec < ( f64 , Pair ) > = Vec :: new ( ) ;
6258 for i in 0 ..boxes. len ( ) {
6359 for j in i + 1 ..boxes. len ( ) {
0 commit comments