@@ -5,15 +5,42 @@ fn read_input(file_path: &str) -> io::Result<String> {
5
5
}
6
6
7
7
fn main ( ) -> io:: Result < ( ) > {
8
- let input = read_input ( "input.txt" ) ?;
9
- let input_slice: Vec < char > = input. chars ( ) . collect ( ) ;
8
+ let file_path =
9
+ "/Users/stianfroystein/src/github.com/stianfro/adventofcode/2015/day-2/input.txt" ;
10
+
11
+ let input = read_input ( file_path) ?;
12
+ let input_slice: Vec < & str > = input. split ( '\n' ) . collect ( ) ;
10
13
11
14
part_one ( input_slice. clone ( ) ) ;
12
- part_two ( input_slice. clone ( ) ) ;
15
+ // part_two(input_slice.clone());
13
16
14
17
Ok ( ( ) )
15
18
}
16
19
17
- fn part_one ( input : Vec < char > ) { }
20
+ fn part_one ( presents : Vec < & str > ) {
21
+ let mut wrapping_total = 0 ;
22
+
23
+ for present in presents {
24
+ if present. is_empty ( ) {
25
+ break ;
26
+ }
27
+
28
+ let dimensions: Vec < & str > = present. split ( 'x' ) . collect ( ) ;
29
+
30
+ let l = dimensions[ 0 ] ;
31
+ let w = dimensions[ 1 ] ;
32
+ let h = dimensions[ 2 ] ;
33
+
34
+ let l_int: i32 = l. parse ( ) . expect ( "not a valid number" ) ;
35
+ let w_int: i32 = w. parse ( ) . expect ( "not a valid number" ) ;
36
+ let h_int: i32 = h. parse ( ) . expect ( "not a valid number" ) ;
37
+
38
+ // TODO: create slice of the sides
39
+ let wrapping = 2 * l_int * w_int + 2 * w_int * h_int + 2 * h_int * l_int;
40
+ wrapping_total += wrapping;
41
+ }
42
+
43
+ println ! ( "part one: {wrapping_total}" ) ;
44
+ }
18
45
19
- fn part_two ( input : Vec < char > ) { }
46
+ // fn part_two(dimensions : Vec<char>) {}
0 commit comments