-
Notifications
You must be signed in to change notification settings - Fork 0
/
Start-Day.ps1
39 lines (32 loc) · 1.25 KB
/
Start-Day.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.DESCRIPTION
This script creates a new folder for the day of the Advent of Code and creates the necessary files to start the day.
.INPUTS
-year: The year of the Advent of Code. Default is the current year.
-day: The day of the Advent of Code. Default is the next day.
.OUTPUTS
A new folder with the name of the day and the necessary files to start the day.
.LINK
https://adventofcode.com/
#>
[CmdletBinding()]
param (
[Parameter()] [int] $year = (Get-Date).Year,
[Parameter()] [int] $day = (Get-ChildItem -Path $year -Directory -Filter "day*").Count + 1
)
$dayPath = "$year\day$day"
$dayPage = Invoke-WebRequest -Uri "https://adventofcode.com/$year/day/$day"
$dayContent = $dayPage.Content -replace "(?s).*<main>(.*)</main>.*", '$1'
New-Item -ItemType Directory -Path $dayPath -Force
New-Item -ItemType Directory -Path "$dayPath\assets" -Force
New-Item -ItemType File -Path "$dayPath\part_one.md" -Force -Value $dayContent
New-Item -ItemType File -Path "$dayPath\part_two.md" -Force -Value $dayContent
New-Item -ItemType File -Path "$dayPath\README.md" -Force -Value "
# AOC DAY $day
---
![img]()
> Difficulty [x/x] :)
### Take a look to the problems and my results:
- [Part 1](./part_one.md)
- [Part 2](./part_two.md)
"