diff options
author | Akshay <[email protected]> | 2020-12-01 13:47:47 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-01 13:47:47 +0000 |
commit | cb13d9733b7af2ee7662ffb428cf6e2a11df138a (patch) | |
tree | 2bc3936f28f21223b13ea7a08689ad1a8a0b89b4 | |
parent | caf1e7203ccdbef4a1913e475f50f7a2a80e20d4 (diff) |
ignore cabal stuff
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Setup.hs | 2 | ||||
-rw-r--r-- | aoc.cabal | 23 | ||||
-rw-r--r-- | default.nix | 11 | ||||
-rw-r--r-- | execs/Day01.hs | 22 | ||||
-rw-r--r-- | input/01 | 200 | ||||
-rw-r--r-- | release.nix | 5 |
7 files changed, 264 insertions, 1 deletions
@@ -1,3 +1,3 @@ | |||
1 | result | 1 | result |
2 | .envrc | 2 | .envrc |
3 | 3 | dist-newstyle | |
diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs | |||
@@ -0,0 +1,2 @@ | |||
1 | import Distribution.Simple | ||
2 | main = defaultMain | ||
diff --git a/aoc.cabal b/aoc.cabal new file mode 100644 index 0000000..c6b9dee --- /dev/null +++ b/aoc.cabal | |||
@@ -0,0 +1,23 @@ | |||
1 | cabal-version: >=1.10 | ||
2 | -- Initial package description 'aoc.cabal' generated by 'cabal init'. For | ||
3 | -- further documentation, see http://haskell.org/cabal/users-guide/ | ||
4 | |||
5 | name: aoc | ||
6 | version: 0.1.0.0 | ||
7 | -- synopsis: | ||
8 | -- description: | ||
9 | -- bug-reports: | ||
10 | -- license: | ||
11 | license-file: LICENSE | ||
12 | author: Akshay | ||
13 | maintainer: [email protected] | ||
14 | -- copyright: | ||
15 | -- category: | ||
16 | build-type: Simple | ||
17 | extra-source-files: CHANGELOG.md | ||
18 | |||
19 | executable Day01 | ||
20 | main-is: Day01.hs | ||
21 | build-depends: base | ||
22 | default-language: Haskell2010 | ||
23 | hs-source-dirs: execs | ||
diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..a4ac4ea --- /dev/null +++ b/default.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | { mkDerivation, base, stdenv }: | ||
2 | mkDerivation { | ||
3 | pname = "aoc"; | ||
4 | version = "0.1.0.0"; | ||
5 | src = ./.; | ||
6 | isLibrary = false; | ||
7 | isExecutable = true; | ||
8 | executableHaskellDepends = [ base ]; | ||
9 | license = "MIT"; | ||
10 | hydraPlatforms = stdenv.lib.platforms.none; | ||
11 | } | ||
diff --git a/execs/Day01.hs b/execs/Day01.hs new file mode 100644 index 0000000..4a10259 --- /dev/null +++ b/execs/Day01.hs | |||
@@ -0,0 +1,22 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Monad | ||
4 | |||
5 | main :: IO () | ||
6 | main = do | ||
7 | n <- map read . lines <$> readFile "input/01" | ||
8 | print . head $ ans1 n | ||
9 | print . head $ ans2 n | ||
10 | |||
11 | ans1 l = do | ||
12 | a <- l | ||
13 | b <- l | ||
14 | guard $ a + b == 2020 | ||
15 | return $ a * b | ||
16 | |||
17 | ans2 l = do | ||
18 | a <- l | ||
19 | b <- l | ||
20 | c <- l | ||
21 | guard $ a + b + c == 2020 | ||
22 | return $ a * b * c | ||
diff --git a/input/01 b/input/01 new file mode 100644 index 0000000..7346cba --- /dev/null +++ b/input/01 | |||
@@ -0,0 +1,200 @@ | |||
1 | 1768 | ||
2 | 1847 | ||
3 | 1905 | ||
4 | 1713 | ||
5 | 1826 | ||
6 | 1846 | ||
7 | 1824 | ||
8 | 1976 | ||
9 | 1687 | ||
10 | 1867 | ||
11 | 1665 | ||
12 | 1606 | ||
13 | 1946 | ||
14 | 1886 | ||
15 | 1858 | ||
16 | 346 | ||
17 | 1739 | ||
18 | 1752 | ||
19 | 1700 | ||
20 | 1922 | ||
21 | 1865 | ||
22 | 1609 | ||
23 | 1617 | ||
24 | 1932 | ||
25 | 1346 | ||
26 | 1213 | ||
27 | 1933 | ||
28 | 834 | ||
29 | 1598 | ||
30 | 1191 | ||
31 | 1979 | ||
32 | 1756 | ||
33 | 1216 | ||
34 | 1820 | ||
35 | 1792 | ||
36 | 1537 | ||
37 | 1341 | ||
38 | 1390 | ||
39 | 1709 | ||
40 | 1458 | ||
41 | 1808 | ||
42 | 1885 | ||
43 | 1679 | ||
44 | 1977 | ||
45 | 1869 | ||
46 | 1614 | ||
47 | 1938 | ||
48 | 1622 | ||
49 | 1868 | ||
50 | 1844 | ||
51 | 1969 | ||
52 | 1822 | ||
53 | 1510 | ||
54 | 1994 | ||
55 | 1337 | ||
56 | 1883 | ||
57 | 1519 | ||
58 | 1766 | ||
59 | 1554 | ||
60 | 1825 | ||
61 | 1828 | ||
62 | 1972 | ||
63 | 1380 | ||
64 | 1878 | ||
65 | 1345 | ||
66 | 1469 | ||
67 | 1794 | ||
68 | 1898 | ||
69 | 1805 | ||
70 | 1911 | ||
71 | 1913 | ||
72 | 1910 | ||
73 | 1318 | ||
74 | 1862 | ||
75 | 1921 | ||
76 | 1753 | ||
77 | 1823 | ||
78 | 1896 | ||
79 | 1316 | ||
80 | 1381 | ||
81 | 1430 | ||
82 | 1962 | ||
83 | 1958 | ||
84 | 1702 | ||
85 | 1923 | ||
86 | 1993 | ||
87 | 1789 | ||
88 | 2002 | ||
89 | 1788 | ||
90 | 1970 | ||
91 | 1955 | ||
92 | 1887 | ||
93 | 1870 | ||
94 | 225 | ||
95 | 1696 | ||
96 | 1975 | ||
97 | 699 | ||
98 | 294 | ||
99 | 1605 | ||
100 | 1500 | ||
101 | 1777 | ||
102 | 1750 | ||
103 | 1857 | ||
104 | 1540 | ||
105 | 1329 | ||
106 | 1974 | ||
107 | 1947 | ||
108 | 1516 | ||
109 | 1925 | ||
110 | 1945 | ||
111 | 350 | ||
112 | 1669 | ||
113 | 1775 | ||
114 | 1536 | ||
115 | 1871 | ||
116 | 1917 | ||
117 | 1249 | ||
118 | 1971 | ||
119 | 2009 | ||
120 | 1585 | ||
121 | 1986 | ||
122 | 1701 | ||
123 | 1832 | ||
124 | 1754 | ||
125 | 1195 | ||
126 | 1697 | ||
127 | 1941 | ||
128 | 1919 | ||
129 | 2006 | ||
130 | 1667 | ||
131 | 1816 | ||
132 | 1765 | ||
133 | 1631 | ||
134 | 2003 | ||
135 | 1861 | ||
136 | 1000 | ||
137 | 1791 | ||
138 | 1786 | ||
139 | 1843 | ||
140 | 1939 | ||
141 | 1951 | ||
142 | 269 | ||
143 | 1790 | ||
144 | 1895 | ||
145 | 1355 | ||
146 | 1833 | ||
147 | 1466 | ||
148 | 1998 | ||
149 | 1806 | ||
150 | 1881 | ||
151 | 1234 | ||
152 | 1856 | ||
153 | 1619 | ||
154 | 1727 | ||
155 | 1874 | ||
156 | 1877 | ||
157 | 195 | ||
158 | 1783 | ||
159 | 1797 | ||
160 | 2010 | ||
161 | 1764 | ||
162 | 1863 | ||
163 | 1852 | ||
164 | 1841 | ||
165 | 1892 | ||
166 | 1562 | ||
167 | 1650 | ||
168 | 1942 | ||
169 | 1695 | ||
170 | 1730 | ||
171 | 1965 | ||
172 | 1632 | ||
173 | 1981 | ||
174 | 1900 | ||
175 | 1991 | ||
176 | 1884 | ||
177 | 1278 | ||
178 | 1062 | ||
179 | 1394 | ||
180 | 1999 | ||
181 | 2000 | ||
182 | 1827 | ||
183 | 1873 | ||
184 | 1926 | ||
185 | 1434 | ||
186 | 1802 | ||
187 | 1579 | ||
188 | 1879 | ||
189 | 1671 | ||
190 | 1549 | ||
191 | 1875 | ||
192 | 1838 | ||
193 | 1338 | ||
194 | 1864 | ||
195 | 1718 | ||
196 | 1800 | ||
197 | 1928 | ||
198 | 1749 | ||
199 | 1990 | ||
200 | 1705 | ||
diff --git a/release.nix b/release.nix new file mode 100644 index 0000000..75d5a3d --- /dev/null +++ b/release.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | let | ||
2 | sources = import ./nix/sources.nix {}; | ||
3 | pkgs = import sources.nixpkgs {}; | ||
4 | in | ||
5 | pkgs.haskellPackages.callPackage ./default.nix {} | ||