File tree 3 files changed +171
-0
lines changed
3 files changed +171
-0
lines changed Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " day25"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ use std:: io:: Read ;
2
+
3
+ fn main ( ) {
4
+ let mut input = String :: new ( ) ;
5
+ std:: io:: stdin ( ) . read_to_string ( & mut input) . unwrap ( ) ;
6
+
7
+ let mut sum = input. lines ( ) . map ( |line| {
8
+ line. chars ( ) . fold ( 0 , |acc, c| {
9
+ acc * 5 + match c {
10
+ '=' => -2 ,
11
+ '-' => -1 ,
12
+ '0' => 0 ,
13
+ '1' => 1 ,
14
+ '2' => 2 ,
15
+ _ => panic ! ( ) ,
16
+ }
17
+ } )
18
+ } ) . sum :: < i64 > ( ) ;
19
+
20
+ let mut digits = [ '0' ; 27 ] ;
21
+
22
+ for c in & mut digits {
23
+ let x = sum + 2 ;
24
+ let digit = x. rem_euclid ( 5 ) - 2 ;
25
+ sum = x. div_euclid ( 5 ) ;
26
+ * c = match digit {
27
+ -2 => '=' ,
28
+ -1 => '-' ,
29
+ 0 => '0' ,
30
+ 1 => '1' ,
31
+ 2 => '2' ,
32
+ _ => panic ! ( ) ,
33
+ } ;
34
+ if sum == 0 {
35
+ break ;
36
+ }
37
+ }
38
+
39
+ for c in digits. into_iter ( ) . rev ( ) . skip_while ( |& c| c == '0' ) {
40
+ print ! ( "{}" , c) ;
41
+ }
42
+ println ! ( ) ;
43
+ }
Original file line number Diff line number Diff line change
1
+ 21-2-0=1-
2
+ 2-11220-==01==2
3
+ 1-2200=1=0--
4
+ 1-10--22=-=-2
5
+ 21120
6
+ 1=0==
7
+ 10=022
8
+ 222--0=10202-0=2
9
+ 1=01==1
10
+ 1021
11
+ 20--221-222000
12
+ 12-1=02--0221=-1
13
+ 11-=-1===2-
14
+ 1-101-=
15
+ 11-21100-===0=-
16
+ 1-
17
+ 2-=
18
+ 1=0=-0
19
+ 10011001=0
20
+ 2--
21
+ 2120=202121
22
+ 1=0
23
+ 10==-
24
+ 22=02102=2-
25
+ 11=0-
26
+ 1==0-1-1=0
27
+ 21===-=-0
28
+ 11220-=2-=20=201
29
+ 2=001
30
+ 1=20--=-
31
+ 1===00
32
+ 12-22012012-21=
33
+ 2=--=20-111=-
34
+ 221
35
+ 12=0-=-=
36
+ 2---102
37
+ 1=1
38
+ 202011021=
39
+ 21=0-0=--1102-1-
40
+ 1=--2102220-2==221=
41
+ 1=10021-=21
42
+ 11=2=202120021-=11
43
+ 1-1012=122=
44
+ 12-01=0=1=0-11=0--
45
+ 100-20=1=-
46
+ 110=0-
47
+ 1=-102
48
+ 2-221=2--010-01
49
+ 12-01220
50
+ 10--10====1-20=-00
51
+ 110
52
+ 1=00==22
53
+ 212-1-222010=2==2=1
54
+ 1=011=1=0
55
+ 1-0
56
+ 1-11221=000-=200221
57
+ 221-00=2=-1-
58
+ 122=1=2
59
+ 101
60
+ 1==2=11=-10
61
+ 220-1--=21=2-02==
62
+ 21--02--0-==1
63
+ 1==0=11012
64
+ 122
65
+ 1000=20=0012
66
+ 22-=0-011110=
67
+ 2=21-1-20212--=
68
+ 1-=202010
69
+ 1-0=-===21-100
70
+ 1-22--21
71
+ 1-12011122=02=-21
72
+ 1-01-2=1000-01=21-
73
+ 12-1-1=1=-=01=-1=
74
+ 202
75
+ 1==-1-00
76
+ 1201--=-=-
77
+ 1=-1--==1122=2=12
78
+ 201020
79
+ 1=-11-0111-00-2
80
+ 10==1==-1=2
81
+ 120=1002-00122
82
+ 1=12
83
+ 2122110
84
+ 1112-10=12==
85
+ 1=02--0-=
86
+ 2-0021-==112=10=
87
+ 2212-022-==10==
88
+ 1001200-1-=
89
+ 2=000-=00--11
90
+ 1==0122120
91
+ 1=1==-=2210-
92
+ 1-02===012
93
+ 12-21-11-1-10
94
+ 2=10==-=11=-
95
+ 22---2=2012-22100
96
+ 1=-0=--
97
+ 1=20--2=1212===12=
98
+ 1=
99
+ 2-
100
+ 1-=2=2-00211-2=0
101
+ 1=222---02=00211-
102
+ 112==10
103
+ 2-0=101-10=02
104
+ 11212101-
105
+ 10-=
106
+ 1=01=2=011=--0
107
+ 21=0-10==22-201
108
+ 1-20=-1=121-
109
+ 120=
110
+ 1-=01=-1-
111
+ 11--1-11=0=221
112
+ 1-=120==
113
+ 20--002=
114
+ 12--22
115
+ 200-=
116
+ 1=1--21=111=--=011-1
117
+ 12011=0=--11
118
+ 1-2
119
+ 121==1
120
+ 10220-==-
You can’t perform that action at this time.
0 commit comments