-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
using System.Diagnostics; namespace AocUtilities; public static class AocInput { public static readonly HttpClient Client = new(); public static readonly string Session = ""; public static readonly string SavePath = $"{AppContext.BaseDirectory}\\input.txt"; public static HttpContent GetHttpInputContent(HttpClient client, string session, int year, int day) { Debug.Assert(!string.IsNullOrWhiteSpace(session)); Debug.Assert(session.All(c => char.ToLower(c) is >= 'a' and <= 'z' or >= '0' and <= '9')); var request = new HttpRequestMessage( HttpMethod.Get, $"https://adventofcode.com/{year}/day/{day}/input"); request.Headers.Add( "Cookie", $"session={session}"); var response = client.Send(request); var content = response.Content; return content; } public static TextReader GetInput(int year, int day) { TextReader reader; if (File.Exists(SavePath)) { reader = File.OpenText(SavePath); return reader; } var httpInputContent = GetHttpInputContent(Client, Session, year, day); var inputStr = httpInputContent.ReadAsStringAsync().Result; Debug.Assert(!inputStr.Contains("Please log in to get your puzzle input")); reader = new StringReader(inputStr); File.WriteAllText(SavePath, inputStr); return reader; } }