From cb13d9733b7af2ee7662ffb428cf6e2a11df138a Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 1 Dec 2020 19:17:47 +0530 Subject: ignore cabal stuff --- .gitignore | 2 +- Setup.hs | 2 + aoc.cabal | 23 +++++++ default.nix | 11 ++++ execs/Day01.hs | 22 +++++++ input/01 | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ release.nix | 5 ++ 7 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 Setup.hs create mode 100644 aoc.cabal create mode 100644 default.nix create mode 100644 execs/Day01.hs create mode 100644 input/01 create mode 100644 release.nix diff --git a/.gitignore b/.gitignore index 86a7bac..f84af70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ result .envrc - +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 @@ +import Distribution.Simple +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 @@ +cabal-version: >=1.10 +-- Initial package description 'aoc.cabal' generated by 'cabal init'. For +-- further documentation, see http://haskell.org/cabal/users-guide/ + +name: aoc +version: 0.1.0.0 +-- synopsis: +-- description: +-- bug-reports: +-- license: +license-file: LICENSE +author: Akshay +maintainer: nerdy@peppe.rs +-- copyright: +-- category: +build-type: Simple +extra-source-files: CHANGELOG.md + +executable Day01 + main-is: Day01.hs + build-depends: base + default-language: Haskell2010 + 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 @@ +{ mkDerivation, base, stdenv }: +mkDerivation { + pname = "aoc"; + version = "0.1.0.0"; + src = ./.; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ base ]; + license = "MIT"; + hydraPlatforms = stdenv.lib.platforms.none; +} 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 @@ +module Main where + +import Control.Monad + +main :: IO () +main = do + n <- map read . lines <$> readFile "input/01" + print . head $ ans1 n + print . head $ ans2 n + +ans1 l = do + a <- l + b <- l + guard $ a + b == 2020 + return $ a * b + +ans2 l = do + a <- l + b <- l + c <- l + guard $ a + b + c == 2020 + 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 @@ +1768 +1847 +1905 +1713 +1826 +1846 +1824 +1976 +1687 +1867 +1665 +1606 +1946 +1886 +1858 +346 +1739 +1752 +1700 +1922 +1865 +1609 +1617 +1932 +1346 +1213 +1933 +834 +1598 +1191 +1979 +1756 +1216 +1820 +1792 +1537 +1341 +1390 +1709 +1458 +1808 +1885 +1679 +1977 +1869 +1614 +1938 +1622 +1868 +1844 +1969 +1822 +1510 +1994 +1337 +1883 +1519 +1766 +1554 +1825 +1828 +1972 +1380 +1878 +1345 +1469 +1794 +1898 +1805 +1911 +1913 +1910 +1318 +1862 +1921 +1753 +1823 +1896 +1316 +1381 +1430 +1962 +1958 +1702 +1923 +1993 +1789 +2002 +1788 +1970 +1955 +1887 +1870 +225 +1696 +1975 +699 +294 +1605 +1500 +1777 +1750 +1857 +1540 +1329 +1974 +1947 +1516 +1925 +1945 +350 +1669 +1775 +1536 +1871 +1917 +1249 +1971 +2009 +1585 +1986 +1701 +1832 +1754 +1195 +1697 +1941 +1919 +2006 +1667 +1816 +1765 +1631 +2003 +1861 +1000 +1791 +1786 +1843 +1939 +1951 +269 +1790 +1895 +1355 +1833 +1466 +1998 +1806 +1881 +1234 +1856 +1619 +1727 +1874 +1877 +195 +1783 +1797 +2010 +1764 +1863 +1852 +1841 +1892 +1562 +1650 +1942 +1695 +1730 +1965 +1632 +1981 +1900 +1991 +1884 +1278 +1062 +1394 +1999 +2000 +1827 +1873 +1926 +1434 +1802 +1579 +1879 +1671 +1549 +1875 +1838 +1338 +1864 +1718 +1800 +1928 +1749 +1990 +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 @@ +let + sources = import ./nix/sources.nix {}; + pkgs = import sources.nixpkgs {}; +in + pkgs.haskellPackages.callPackage ./default.nix {} -- cgit v1.2.3