Added new data and answers for testing, as well as fixed Day3 console print
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-12-05 22:40:17 -08:00
parent ee9ecad64a
commit f369fc86ed
18 changed files with 1923 additions and 7 deletions

View File

@@ -11,8 +11,8 @@ namespace AdventOfCode.InputFetcher
private static HttpClient _client;
static void Main(string[] args)
{
Console.WriteLine("Please select your year! Default: 2022");
var year = SanitizeInput(Console.ReadLine(), "2022");
Console.WriteLine("Please select your year! Default: 2023");
var year = SanitizeInput(Console.ReadLine(), "2023");
Console.WriteLine("Please enter your session key for advent of code:");
var sessionKey = Console.ReadLine();
Console.WriteLine("Please input the target directory for the input files! Default: Current working directory");
@@ -36,7 +36,15 @@ namespace AdventOfCode.InputFetcher
bool dataFileExistsOnDisk = filesOnDisk.EnumerateFiles().Any(x => x.Name == dataFileName);
if (!dataFileExistsOnDisk || (overwrite.ToUpper() == "Y"))
{
File.WriteAllText(targetDir + Path.DirectorySeparatorChar + dataFileName, PullDataForDay(year, day));
try
{
File.WriteAllText(targetDir + Path.DirectorySeparatorChar + dataFileName, PullDataForDay(year, day));
}catch(FileNotFoundException e)
{
//Input data not available yet
continue;
}
}
@@ -85,6 +93,7 @@ namespace AdventOfCode.InputFetcher
private static string ExecuteWebRequest(string url)
{
var resp = _client.GetAsync(url).Result;
if (resp.StatusCode == System.Net.HttpStatusCode.NotFound) throw new FileNotFoundException("No day input was found!");
return resp.Content.ReadAsStringAsync().Result;
}