commit 3f7baccf0cde2f019be3e000aac315e8b8000812 Author: Daniele Fucini Date: Mon Dec 1 19:31:18 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f5022c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +input +.stack-work diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f21b08b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2025] [Daniele Fucini] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cdeaa62 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Advent of Code 2025 + +|Day|Stars|Day|Stars| +|---|-----|---|-----| +|01 | |07 | | +|02 | |08 | | +|03 | |09 | | +|04 | |10 | | +|05 | |11 | | +|06 | |12 | | 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/adventofcode2025.cabal b/adventofcode2025.cabal new file mode 100644 index 0000000..d01961a --- /dev/null +++ b/adventofcode2025.cabal @@ -0,0 +1,32 @@ +cabal-version: 2.2 + +name: adventofcode2025 +version: 0.1.0.0 +-- synopsis: +-- description: +homepage: https://git.shouldnt.work/fuxino/AdventOfCode2025 +license: MIT +license-file: LICENSE +author: Daniele Fucini +maintainer: dfucini@gmail.com +copyright: 2025 Daniele Fucini +category: Web +build-type: Simple +extra-source-files: README.md + +executable adventofcode2025 + hs-source-dirs: src + main-is: Main.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + ghc-options: -Wall + -Wcompat + -Widentities + -Wincomplete-record-updates + -Wincomplete-uni-patterns + -Wmissing-export-lists + -Wmissing-home-modules + -Wpartial-fields + -Wredundant-constraints + other-modules: + Day01 diff --git a/src/Day01.hs b/src/Day01.hs new file mode 100644 index 0000000..9cd710c --- /dev/null +++ b/src/Day01.hs @@ -0,0 +1,27 @@ +module Day01 + ( day01_1, + ) +where + +parseInput :: IO [String] +parseInput = do + lines <$> readFile "input/day1.txt" + +rotate :: Int -> String -> Int +rotate n ('L':xs) = (n - read xs) `mod` 100 +rotate n ('R':xs) = (n + read xs) `mod` 100 +rotate n _ = n + +getPassword :: Int -> Int -> [String] -> Int +getPassword pass 0 [] = pass + 1 +getPassword pass _ [] = pass +getPassword pass 0 (x:xs) = getPassword (pass + 1) (rotate 0 x) xs +getPassword pass curr (x:xs) = getPassword pass (rotate curr x) xs + +day01_1 :: IO () +day01_1 = do + input <- parseInput + let result = getPassword 0 50 input + putStrLn $ + "Day 1, Puzzle 1 solution: " + ++ show result diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..8d31432 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,15 @@ +module Main (main) where + +import Day01 (day01_1) +import System.Environment (getArgs) + +main :: IO () +main = do + args <- getArgs + case args of + "1" : "1" : _ -> day01_1 + "1" : _ -> do + day01_1 + "all" : _ -> do + day01_1 + _ -> error "Not implemented" diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..9e86b53 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,66 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/configure/yaml/ + +# A 'specific' Stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# snapshot: lts-23.14 +# snapshot: nightly-2025-02-15 +# snapshot: ghc-9.8.4 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# snapshot: ./custom-snapshot.yaml +# snapshot: https://example.com/snapshots/2024-01-01.yaml +snapshot: lts-24.0 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# subdirs: +# - auto-update +# - wai +packages: +- . +# Dependency packages to be pulled from upstream that are not in the snapshot. +# These entries can reference officially published versions as well as +# forks / in-progress versions pinned to a git hash. For example: +# +# extra-deps: +# - acme-missiles-0.3 +# - git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# +# extra-deps: [] + +# Override default flag values for project packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of Stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=3.5" +# +# Override the architecture used by Stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by Stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..76a7254 --- /dev/null +++ b/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/topics/lock_files + +packages: [] +snapshots: +- completed: + sha256: 3f59fb01f884a786c64e247ffe145df5f6045d929b1d2752b5ce768e37fd44e5 + size: 724510 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/0.yaml + original: lts-24.0