aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-01 13:47:47 +0000
committerAkshay <[email protected]>2020-12-01 13:47:47 +0000
commitcb13d9733b7af2ee7662ffb428cf6e2a11df138a (patch)
tree2bc3936f28f21223b13ea7a08689ad1a8a0b89b4
parentcaf1e7203ccdbef4a1913e475f50f7a2a80e20d4 (diff)
ignore cabal stuff
-rw-r--r--.gitignore2
-rw-r--r--Setup.hs2
-rw-r--r--aoc.cabal23
-rw-r--r--default.nix11
-rw-r--r--execs/Day01.hs22
-rw-r--r--input/01200
-rw-r--r--release.nix5
7 files changed, 264 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 86a7bac..f84af70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
1result 1result
2.envrc 2.envrc
3 3dist-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 @@
1import Distribution.Simple
2main = 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 @@
1cabal-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
5name: aoc
6version: 0.1.0.0
7-- synopsis:
8-- description:
9-- bug-reports:
10-- license:
11license-file: LICENSE
12author: Akshay
13maintainer: [email protected]
14-- copyright:
15-- category:
16build-type: Simple
17extra-source-files: CHANGELOG.md
18
19executable 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 }:
2mkDerivation {
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 @@
1module Main where
2
3import Control.Monad
4
5main :: IO ()
6main = do
7 n <- map read . lines <$> readFile "input/01"
8 print . head $ ans1 n
9 print . head $ ans2 n
10
11ans1 l = do
12 a <- l
13 b <- l
14 guard $ a + b == 2020
15 return $ a * b
16
17ans2 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 @@
11768
21847
31905
41713
51826
61846
71824
81976
91687
101867
111665
121606
131946
141886
151858
16346
171739
181752
191700
201922
211865
221609
231617
241932
251346
261213
271933
28834
291598
301191
311979
321756
331216
341820
351792
361537
371341
381390
391709
401458
411808
421885
431679
441977
451869
461614
471938
481622
491868
501844
511969
521822
531510
541994
551337
561883
571519
581766
591554
601825
611828
621972
631380
641878
651345
661469
671794
681898
691805
701911
711913
721910
731318
741862
751921
761753
771823
781896
791316
801381
811430
821962
831958
841702
851923
861993
871789
882002
891788
901970
911955
921887
931870
94225
951696
961975
97699
98294
991605
1001500
1011777
1021750
1031857
1041540
1051329
1061974
1071947
1081516
1091925
1101945
111350
1121669
1131775
1141536
1151871
1161917
1171249
1181971
1192009
1201585
1211986
1221701
1231832
1241754
1251195
1261697
1271941
1281919
1292006
1301667
1311816
1321765
1331631
1342003
1351861
1361000
1371791
1381786
1391843
1401939
1411951
142269
1431790
1441895
1451355
1461833
1471466
1481998
1491806
1501881
1511234
1521856
1531619
1541727
1551874
1561877
157195
1581783
1591797
1602010
1611764
1621863
1631852
1641841
1651892
1661562
1671650
1681942
1691695
1701730
1711965
1721632
1731981
1741900
1751991
1761884
1771278
1781062
1791394
1801999
1812000
1821827
1831873
1841926
1851434
1861802
1871579
1881879
1891671
1901549
1911875
1921838
1931338
1941864
1951718
1961800
1971928
1981749
1991990
2001705
diff --git a/release.nix b/release.nix
new file mode 100644
index 0000000..75d5a3d
--- /dev/null
+++ b/release.nix
@@ -0,0 +1,5 @@
1let
2 sources = import ./nix/sources.nix {};
3 pkgs = import sources.nixpkgs {};
4in
5 pkgs.haskellPackages.callPackage ./default.nix {}