diff --git a/APIHandler.cs b/APIHandler.cs index 32d8c7c..31e30ef 100644 --- a/APIHandler.cs +++ b/APIHandler.cs @@ -49,6 +49,18 @@ private async Task SendRequestAsync(HttpMethod method, string uri, HttpC } } + public async Task GetSampleInputTextAsync(int part = 1) + { + var response = await SendRequestAsync(HttpMethod.Get, $"https://adventofcode.com/{_year}/day/{_day}"); + + var regex = new Regex(@"
(?(.*?\n)*?)<\/code><\/pre>");
+        var matches = regex.Matches(response);
+
+        if (matches.Count >= part) { return matches[part - 1].Groups["sample"].Value.TrimEnd('\n'); }
+        else { throw new Exception("sample could not be found"); }
+    }
+    public async Task GetSampleInputLinesAsync(int part = 1) => (await GetSampleInputTextAsync(part)).Split('\n');
+
     public async Task GetInputTextAsync() => (await SendRequestAsync(HttpMethod.Get, $"https://adventofcode.com/{_year}/day/{_day}/input")).TrimEnd('\n');
     public async Task GetInputLinesAsync() => (await GetInputTextAsync()).Split('\n');
 
diff --git a/AoC.API.csproj b/AoC.API.csproj
index 79ec9a0..5e65f39 100644
--- a/AoC.API.csproj
+++ b/AoC.API.csproj
@@ -11,7 +11,7 @@
     AoC, Advent-of-Code, API
     https://github.com/antonio-subasic/AoC.API
     README.md
-    2.1.5
+    2.2.5
   
 
   
diff --git a/README.md b/README.md
index 7454d01..a1567b7 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,8 @@ a simple [Advent of Code](https://adventofcode.com) API
 - [Add NuGet package](#add-nuget-package)
 - [Session initialization](#session-initialization)
 - [Features](#features)
-    - [Get input file](#get-input-file)
+    - [Get input](#get-input)
+    - [Get sample input](#get-sample-input)
     - [Get achieved stars](#get-achieved-stars)
     - [Submit answer](#submit-answer)
 
@@ -48,11 +49,20 @@ var client = new Session("session cookie", string input, Regex pattern);
 
 # Features
 
-## Get input file
+## Get input
 
 ```csharp
-string inputText = await client.GetInputTextAsync(); // input file (raw text)
-string inputLines = await client.GetInputLinesAsync(); // input file (lines array)
+string inputText = await client.GetInputTextAsync(); // input (raw text)
+string inputLines = await client.GetInputLinesAsync(); // input (lines array)
+```
+
+
+ +## Get sample input + +```csharp +string sampleInputText = await client.GetSampleInputTextAsync(int part); // sample input (raw text) +string sampleInputLines = await client.GetSampleInputLinesAsync(int part); // sample input (lines array) ```