Browse Source

Getting reading to solve this

main
Sam Hatfield 5 months ago
parent
commit
209673d7d3
Signed by: sehqlr GPG Key ID: 6B1E0EDE1530CA2B
  1. 1
      .gitignore
  2. 16
      Main.hs
  3. 27
      advent-of-code.cabal
  4. 200
      input.txt
  5. 16
      package.yaml
  6. 12
      shell.nix
  7. 4
      stack.yaml
  8. 12
      stack.yaml.lock

1
.gitignore

@ -1,2 +1,3 @@
dist*
.stack-work

16
Main.hs

@ -1,4 +1,18 @@
module Main where
import Data.Set (Set)
import qualified Data.Set as Set
import qualified Data.Text.IO as TIO
import qualified Data.Text as T
import Data.Text.Read
main :: IO ()
main = putStrLn "Hello, Haskell!"
main = do
inputs <- TIO.readFile "input.txt"
let inputs' = T.lines inputs
let xs = map decimal inputs'
let ys = map (2020-) xs
let match = (Set.fromList xs) `Set.intersection` (Set.fromList ys)
putStrLn $ show $ Set.toList match

27
advent-of-code.cabal

@ -0,0 +1,27 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.34.2.
--
-- see: https://github.com/sol/hpack
name: advent-of-code
version: 0.1.0
homepage: https://git.bytes.zone/sehqlr/advent-of-code
author: Sam Hatfield <hey@samhatfield.me>
maintainer: Sam Hatfield <hey@samhatfield.me>
license: MIT
build-type: Simple
source-repository head
type: git
location: https://git.bytes.zone/sehqlr/advent-of-code
executable advent-of-code
main-is: Main.hs
other-modules:
Paths_advent_of_code
build-depends:
base
, containers
, text
default-language: Haskell2010

200
input.txt

@ -0,0 +1,200 @@
1765
1742
1756
1688
1973
1684
1711
1728
1603
1674
1850
1836
1719
1937
1970
1770
1954
1848
1885
1851
1474
1801
1769
1904
1906
1739
1717
1830
1985
1930
1791
1977
1713
1787
1773
1672
1750
1931
1807
1762
1835
1736
1979
1923
1782
1797
1822
1903
1729
343
1678
1753
1873
1358
1987
1821
1761
1988
1886
1669
857
1894
1404
1909
1789
1752
1882
1969
1892
1701
1956
1839
483
1897
1730
1829
1879
1810
1755
1799
1932
1715
1809
418
1896
1691
1749
1922
1631
1780
1734
1859
1695
1548
1948
1997
1921
1994
1369
1364
1764
1697
1833
1239
616
1786
1890
677
1867
1705
1993
1925
1774
1732
1686
1847
1911
1841
1962
1907
1919
1725
1687
1236
1864
1855
1928
1941
1709
1683
1676
1889
1982
1595
1735
1857
1731
1816
2003
1724
741
1655
1308
1959
1955
1768
1795
1804
1961
1693
1884
1813
1927
1845
1689
1646
1803
2008
1599
1984
1871
1814
1918
1990
1858
1908
1949
1980
1618
1718
1712
1989
1876
1947
1974
1838
1865
1842
1817
680
1986
1812
1895
1991
1644
1877
1880
1792
1800
1899
1806
1699
1685
1793
1647
1429
1751
1722
1887
1968

16
package.yaml

@ -0,0 +1,16 @@
spec-version: 0.30.0
name: advent-of-code
version: 0.1.0
homepage: "https://git.bytes.zone/sehqlr/advent-of-code"
author: "Sam Hatfield <hey@samhatfield.me>"
license: MIT
build-type: Simple
git: "https://git.bytes.zone/sehqlr/advent-of-code"
dependencies:
- base
- containers
- text
executable:
main: Main.hs

12
shell.nix

@ -1,6 +1,8 @@
(import ./default.nix {}).shellFor {
tools = {
cabal = "3.2.0.0";
hlint = "latest";
};
{ ghc }:
with (import <nixpkgs> { });
haskell.lib.buildStackProject {
inherit ghc;
name = "adventEnv";
buildInputs = [ ];
}

4
stack.yaml

@ -64,3 +64,7 @@ packages:
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
nix:
enable: true
shell-file: shell.nix

12
stack.yaml.lock

@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
size: 524996
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/27.yaml
sha256: 7ea31a280c56bf36ff591a7397cc384d0dff622e7f9e4225b47d8980f019a0f0
original: lts-14.27
Loading…
Cancel
Save