Skip to content

Commit 0b51478

Browse files
committed
FInish day 1
0 parents  commit 0b51478

File tree

3 files changed

+232
-0
lines changed

3 files changed

+232
-0
lines changed

1/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module 1
2+
3+
go 1.15

1/input.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
1429
2+
1368
3+
1661
4+
1687
5+
1593
6+
1495
7+
1565
8+
1500
9+
1635
10+
1845
11+
1645
12+
1999
13+
1415
14+
1054
15+
1930
16+
1774
17+
1405
18+
1993
19+
1757
20+
1623
21+
1675
22+
1665
23+
631
24+
1950
25+
1702
26+
1311
27+
1509
28+
1790
29+
1643
30+
1884
31+
226
32+
1455
33+
1679
34+
1746
35+
1284
36+
1342
37+
1684
38+
1543
39+
1396
40+
1806
41+
1523
42+
1363
43+
1011
44+
1577
45+
1767
46+
1287
47+
1885
48+
1517
49+
1556
50+
1722
51+
1260
52+
1624
53+
1466
54+
1263
55+
1162
56+
1688
57+
1202
58+
1913
59+
1964
60+
1385
61+
1970
62+
1976
63+
1431
64+
858
65+
1748
66+
1544
67+
1438
68+
1300
69+
1926
70+
1587
71+
1376
72+
1939
73+
1039
74+
1639
75+
1539
76+
1491
77+
1631
78+
1521
79+
1564
80+
1507
81+
1637
82+
1534
83+
1713
84+
1533
85+
1118
86+
1356
87+
2003
88+
282
89+
1079
90+
1837
91+
1259
92+
1941
93+
1836
94+
1903
95+
1433
96+
1467
97+
1027
98+
1441
99+
1048
100+
1742
101+
1087
102+
1872
103+
1476
104+
1657
105+
1361
106+
1182
107+
1494
108+
1529
109+
1822
110+
1444
111+
1330
112+
1514
113+
1723
114+
1432
115+
1683
116+
1997
117+
1443
118+
1474
119+
1932
120+
1504
121+
1313
122+
1765
123+
19
124+
1784
125+
1619
126+
992
127+
1560
128+
1680
129+
1626
130+
1558
131+
1899
132+
1293
133+
1676
134+
1161
135+
1140
136+
1341
137+
1597
138+
1628
139+
1611
140+
1302
141+
1269
142+
1241
143+
1952
144+
1591
145+
1726
146+
428
147+
1703
148+
1289
149+
1109
150+
1478
151+
1002
152+
1817
153+
1849
154+
1838
155+
1319
156+
1641
157+
583
158+
1920
159+
1453
160+
1411
161+
1870
162+
1763
163+
1469
164+
1646
165+
1719
166+
1213
167+
1462
168+
1545
169+
1682
170+
1711
171+
18
172+
2004
173+
1252
174+
1620
175+
1559
176+
1315
177+
781
178+
1656
179+
1987
180+
1436
181+
1630
182+
1985
183+
1897
184+
1551
185+
1296
186+
1282
187+
1735
188+
1320
189+
1659
190+
1271
191+
1380
192+
1274
193+
1876
194+
1492
195+
1298
196+
1399
197+
1692
198+
1265
199+
1555
200+
1337

1/main.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"math/rand"
7+
"strconv"
8+
"strings"
9+
)
10+
11+
func main() {
12+
data, err := ioutil.ReadFile("input.txt")
13+
if err != nil {
14+
fmt.Println("File reading error", err)
15+
return
16+
}
17+
lines := strings.Split(string(data), "\n")
18+
19+
for {
20+
num1, _ := strconv.Atoi(lines[rand.Intn(len(lines))])
21+
num2, _ := strconv.Atoi(lines[rand.Intn(len(lines))])
22+
23+
if num1+num2 == 2020 {
24+
fmt.Println(num1, " * ", num2, " = ", num1*num2)
25+
break
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)