Skip to content

Commit 084c39d

Browse files
committedDec 1, 2017
setup and day 1 part 1
1 parent 9552cd3 commit 084c39d

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
inputs/
2+
13
dist
24
dist-*
35
cabal-dev

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# adventofcode2017
2+
it's a thing

‎Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

‎adventofcode2017.cabal

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: adventofcode2017
2+
version: 0.1.0.0
3+
synopsis: Short description of your package
4+
homepage: https://github.com/pfcm/adventofcode2017#readme
5+
license: BSD3
6+
author: pfcm
7+
maintainer: pfcmathews@gmail.com
8+
copyright: 2017 pfcm
9+
category: ???
10+
build-type: Simple
11+
extra-source-files: README.md
12+
cabal-version: >=1.10
13+
14+
-- To avoid duplicated efforts in documentation and dealing with the
15+
-- complications of embedding Haddock markup inside cabal files, it is
16+
-- common to point users to the README.md file.
17+
description: Please see the README on Github at <https://github.com/githubuser/adventofcode2017#readme>
18+
19+
library
20+
hs-source-dirs: days
21+
build-depends: base >= 4.7 && < 5
22+
default-language: Haskell2010
23+
24+
executable first
25+
hs-source-dirs: days
26+
main-is: First.hs
27+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
28+
build-depends: base
29+
default-language: Haskell2010
30+
31+
source-repository head
32+
type: git
33+
location: https://github.com/githubuser/adventofcode2017

‎days/First.hs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Data.Char
2+
3+
4+
circularSqueeze :: Eq a => [a] -> [a]
5+
circularSqueeze [] = []
6+
circularSqueeze [x] = []
7+
circularSqueeze list =
8+
let
9+
front = head list
10+
squeeze (x:y:xs)
11+
| x == y = x : squeeze (y:xs)
12+
| otherwise = squeeze $ y:xs
13+
squeeze [x] = [x | x == front]
14+
squeeze _ = []
15+
in squeeze list
16+
17+
18+
solveCaptcha :: [Int] -> Int
19+
solveCaptcha = sum . circularSqueeze
20+
21+
22+
main = do
23+
inputs <- getLine
24+
print . solveCaptcha . map digitToInt $ inputs

‎stack.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
# Some commonly used options have been documented as comments in this file.
4+
# For advanced use and comprehensive documentation of the format, please see:
5+
# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+
# A snapshot resolver dictates the compiler version and the set of packages
9+
# to be used for project dependencies. For example:
10+
#
11+
# resolver: lts-3.5
12+
# resolver: nightly-2015-09-21
13+
# resolver: ghc-7.10.2
14+
# resolver: ghcjs-0.1.0_ghc-7.10.2
15+
# resolver:
16+
# name: custom-snapshot
17+
# location: "./custom-snapshot.yaml"
18+
resolver: lts-9.14
19+
20+
# User packages to be built.
21+
# Various formats can be used as shown in the example below.
22+
#
23+
# packages:
24+
# - some-directory
25+
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
26+
# - location:
27+
# git: https://github.com/commercialhaskell/stack.git
28+
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
29+
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
30+
# extra-dep: true
31+
# subdirs:
32+
# - auto-update
33+
# - wai
34+
#
35+
# A package marked 'extra-dep: true' will only be built if demanded by a
36+
# non-dependency (i.e. a user package), and its test suites and benchmarks
37+
# will not be run. This is useful for tweaking upstream packages.
38+
packages:
39+
- .
40+
# Dependency packages to be pulled from upstream that are not in the resolver
41+
# (e.g., acme-missiles-0.3)
42+
extra-deps: []
43+
44+
# Override default flag values for local packages and extra-deps
45+
flags: {}
46+
47+
# Extra package databases containing global packages
48+
extra-package-dbs: []
49+
50+
# Control whether we use the GHC we find on the path
51+
# system-ghc: true
52+
#
53+
# Require a specific version of stack, using version ranges
54+
# require-stack-version: -any # Default
55+
# require-stack-version: ">=1.5"
56+
#
57+
# Override the architecture used by stack, especially useful on Windows
58+
# arch: i386
59+
# arch: x86_64
60+
#
61+
# Extra directories used by stack for building
62+
# extra-include-dirs: [/path/to/dir]
63+
# extra-lib-dirs: [/path/to/dir]
64+
#
65+
# Allow a newer minor version of GHC than the snapshot specifies
66+
# compiler-check: newer-minor

0 commit comments

Comments
 (0)
Please sign in to comment.