-
Notifications
You must be signed in to change notification settings - Fork 0
/
01.rb
210 lines (207 loc) · 1.11 KB
/
01.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
ns = DATA.each_line.map &:to_i
[2, 3].each do |n|
puts ns.combination(n).find { |c| c.sum == 2020 }.inject(:*)
end
# 889779
# 76110336
__END__
1732
1972
1822
1920
1847
1718
1827
1973
1936
1865
1817
1954
1939
1979
1846
1989
1818
398
1786
1900
1949
1161
609
1967
1845
1795
1874
1982
2010
1494
1752
1803
1908
1876
1977
1999
1858
1885
1975
1878
1784
1787
1765
1778
1893
1746
1807
1966
1991
1905
1970
1942
1792
1750
713
1871
1860
1931
1976
1771
128
390
2006
1801
1946
1914
1833
1515
1958
1737
1887
1962
1895
2004
1747
1841
1793
1948
1790
1808
1957
1770
1960
1952
1932
1782
1762
1898
1919
1909
1929
1964
1848
1959
1381
280
1899
1855
1849
1889
1772
1843
1767
1830
1838
1869
1926
1768
1789
1791
1888
1371
2001
1943
1741
1904
1468
1969
1910
649
1953
1916
1852
1996
1842
1950
1850
1998
1963
1780
1883
1955
443
1773
1896
1985
1809
2007
1819
1891
1853
1802
1861
1813
1831
1974
1915
1997
2000
1945
1832
1763
1981
1922
1862
1944
1925
1742
1744
1994
1961
1881
1937
1911
1788
1971
1890
1734
1781
1984
1912
1834
1766
1769
1797
195
1965
1934
1894
1928
1759
1812
1758
1988
1821
1776
2009
1749
1857
1785
1824
1796
1930
1777
1886
477
1761
1800
1745
1993