-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.c
49 lines (47 loc) · 2.03 KB
/
day1.c
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
// Advent of Code Day 1
// @curiouskiwi
// 2 Dec 2020
#include <stdio.h>
int main(void)
{
int nums[] = {1735,1700,1358,1908,1634,2006,762,1492,1917,1591,
1571,1283,1744,1815,1383,1787,1832,1032,1845,1406,
1978,1263,1450,1364,1594,1877,1346,1695,1501,1266,
1729,1476,1558,1684,1295,1267,1341,1415,1491,1640,
1756,1330,1987,1969,1844,1706,1654,1580,1405,1419,
1367,1277,1992,1953,1499,1470,2000,1739,1889,1670,
1776,1798,1308,1890,1626,1284,1315,1869,1514,1214,
1648,1418,1329,1795,1385,1477,1984,1796,1515,2001,
1155,1800,1965,1971,1100,1650,1686,1911,1560,1912,
1721,1658,1738,1885,1028,266,1989,1704,1388,1498,
1769,1453,925,1588,1828,1024,1671,1998,1942,1636,
1382,993,1703,1475,1391,1970,1841,1952,1446,1347,
1395,1440,1980,1386,1922,1857,1291,1808,1335,1876,
1576,1436,634,1557,1782,1881,1955,1765,1736,1585,
1858,1862,989,1661,1757,1775,1693,1842,1660,1647,
870,1928,1597,1420,1646,1821,2009,1866,1947,1593,
1788,1369,1525,1256,1846,1445,1907,1750,1906,1849,
765,1342,1811,1260,1466,1424,1823,1767,1290,1840,
1825,1287,1384,1996,1627,1983,1328,1674,1676,1727,
1810,1394,799,1723,1293,1273,1317,1749,1552,1645};
int i, j, k;
int counter =0;
for (i = 0; i < 200; i++)
{
for (j = i + 1; j < 200; j++)
{
for (k = j + 1; k < 200; k++)
{
counter++;
if (nums[i] + nums[j] + nums[k] == 2020)
{
// printf("%i,%i,%i, %i * %i * %i == %i\n", i, j, k, nums[i], nums[j], nums[k], nums[i] * nums[j] * nums[k]);
break;
}
}
if (k < 200) break;
}
if (j < 200) break;
}
printf("%i\n", counter);
}