File tree 3 files changed +61
-0
lines changed
3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,4 @@ Cargo.lock
11
11
* .idea
12
12
* .iml
13
13
* input.txt
14
+ * input
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " d4-p1"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let input = include_str ! ( "../../input" ) ;
3
+ println ! ( "{}" , solve_input( input) ) ;
4
+ }
5
+
6
+ fn solve_input ( input : & str ) -> u16 {
7
+ // https://www.youtube.com/watch?v=tiLwW8StyBc
8
+ let zoek = Woordzoeker :: from ( input) ;
9
+
10
+ zoek. find_str ( "XMAS" ) ;
11
+ 1
12
+ }
13
+
14
+ #[ derive( Debug ) ]
15
+ struct Woordzoeker ( Vec < Vec < char > > ) ;
16
+
17
+ impl Woordzoeker {
18
+ fn print ( & self ) {
19
+ self . 0 . iter ( ) . for_each ( |row| {
20
+ println ! ( "{}" , row. iter( ) . collect:: <String >( ) ) ;
21
+ } ) ;
22
+ println ! ( ) ;
23
+ }
24
+
25
+ fn rotate ( & self ) -> Self {
26
+ let columns = self . 0 . len ( ) ; // (m) length
27
+ let rows = self . 0 [ 0 ] . len ( ) ; // (n) width
28
+
29
+ let mut rotated: Vec < Vec < char > > = vec ! [ ] ;
30
+ for i in 0 ..rows {
31
+ let mut row = vec ! [ ] ;
32
+ for j in 0 ..columns {
33
+ row. push ( self . 0 [ j] [ i] ) ;
34
+ }
35
+ rotated. push ( row) ;
36
+ }
37
+
38
+ Woordzoeker ( rotated)
39
+ }
40
+
41
+ fn find_str ( & self , target : & str ) {
42
+ }
43
+ }
44
+
45
+ impl From < & str > for Woordzoeker {
46
+ fn from ( aoc_input : & str ) -> Self {
47
+ Woordzoeker (
48
+ aoc_input
49
+ . lines ( )
50
+ . map ( |line| line. chars ( ) . collect ( ) )
51
+ . collect ( )
52
+ )
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments