-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def exampleInput := | ||
"..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Aoc2024.Day03.Solve | ||
import Aoc2024.CustomMonadLift | ||
|
||
def solve (name: String) (inputPath: String) : IO Unit := do | ||
IO.println name | ||
let input <- IO.FS.readFile inputPath | ||
IO.println s!"Part 1: {<- parseAndSolvePart1 input}" | ||
IO.println s!"Part 2: {<- parseAndSolvePart2 input}" | ||
|
||
def main : IO Unit := do | ||
IO.println "Day 03" | ||
IO.println "" | ||
solve "Example" "Aoc2024/Day03/inputs/example.txt" | ||
IO.println "" | ||
solve "Puzzle" "Aoc2024/Day03/inputs/input.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Aoc2024.Day03.Examples | ||
import Std | ||
open Std.Internal.Parsec.String | ||
open Std.Internal.Parsec | ||
|
||
private def inputParser : Parser (List Int) := sorry | ||
|
||
def parseThings : String -> Except String (List Int) := inputParser.run | ||
|
||
-- #guard parseReports exampleInput == Except.ok 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Aoc2024.Utils | ||
import Aoc2024.Day03.Examples | ||
import Aoc2024.Day03.Parser | ||
|
||
private def solvePart1 (things : List Int) : Int := sorry | ||
|
||
def parseAndSolvePart1 (s : String): Except String Int := parseThings s |>.map solvePart1 | ||
|
||
-- #guard parseAndSolvePart1 exampleInput == Except.ok 2 | ||
|
||
private def solvePart2 (things : List Int) : Int := sorry | ||
|
||
def parseAndSolvePart2 (s : String): Except String Int := parseThings s |>.map solvePart2 | ||
|
||
-- #guard parseAndSolvePart2 exampleInput == Except.ok 4 |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 NN" | ||
exit 1 | ||
fi | ||
|
||
day_number=$(printf "%02d" "$1") | ||
source_dir="Aoc2024/DayXX" | ||
target_dir="Aoc2024/Day$day_number" | ||
|
||
# Ensure the target day is in the correct format | ||
if [[ ! $day_number =~ ^[0-9]{2}$ ]]; then | ||
echo "Error: target day must be in the format 'NN' where NN is a two-digit number." | ||
exit 1 | ||
fi | ||
|
||
# Copy directory to new location | ||
cp -R "$source_dir" "$target_dir" | ||
|
||
# Replace XX with NN in file contents | ||
find "$target_dir" -type f -exec sed -i '' "s/XX/${day_number}/g" {} + | ||
|
||
# # Rename files and directories containing XX | ||
# find "$target_dir" -depth -name "*XX*" | while read path; do | ||
# new_path=$(echo "$path" | sed "s/XX/${target_dir:3}/g") | ||
# mv "$path" "$new_path" | ||
# done | ||
|
||
echo "Directory $source_dir successfully copied to $target_dir and updated." |