Added drone configuration for building and testing
Some checks failed
continuous-integration/drone Build is failing
Some checks failed
continuous-integration/drone Build is failing
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="_2021\" />
|
||||
<Folder Include="_2022\Day11\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -8,7 +8,15 @@ namespace AdventOfCode.Common
|
||||
{
|
||||
public static int ToInt(this string str)
|
||||
{
|
||||
return Convert.ToInt32(str);
|
||||
try
|
||||
{
|
||||
return Convert.ToInt32(str);
|
||||
}catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunksize)
|
||||
|
||||
20
AdventOfCode/Common/IgnoreTestAnswerAttribute.cs
Normal file
20
AdventOfCode/Common/IgnoreTestAnswerAttribute.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AdventOfCode.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace AdventOfCode.Common
|
||||
{
|
||||
public class IgnoreTestAnswerAttribute : Attribute
|
||||
{
|
||||
private AOCVersion[] _versions;
|
||||
public IgnoreTestAnswerAttribute(params AOCVersion[] versions)
|
||||
{
|
||||
this._versions = versions;
|
||||
}
|
||||
|
||||
public bool ShouldIgnoreAnswer(AOCVersion version)
|
||||
{
|
||||
return _versions.Any(x => x == version);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,6 @@ namespace AdventOfCode._2022.Day10
|
||||
_cycle++; //Increase it after we draw CRT screen but before we do the cycle check for part A
|
||||
if (_version == AOCVersion.A && CHECK_CYCLES.Any(x => x == _cycle))
|
||||
{
|
||||
Console.WriteLine($"Cycle {_cycle} has register value of {_registerX} and a strength of {_cycle * _registerX}");
|
||||
_sumOfStregnth += _cycle * _registerX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
namespace AdventOfCode._2022.Day10
|
||||
{
|
||||
[AOC(year: 2022, day: 10)]
|
||||
[IgnoreTestAnswer(AOCVersion.B)]
|
||||
public class Day10 : AOCDay
|
||||
{
|
||||
protected override AOCResponse ExecutePartA()
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace AdventOfCode._2022
|
||||
var crates = input.Take(Array.FindIndex(input, x => string.IsNullOrEmpty(x)));
|
||||
var moves = input.Skip(crates.Count() + 1);
|
||||
var crateBoard = new CargoCrateBoard(_request.Version, crates.ToArray(), moves.ToArray());
|
||||
_response.Answer = string.Join(" ", crateBoard.GetResults());
|
||||
_response.Answer = string.Join("", crateBoard.GetResults()).Replace("[", string.Empty).Replace("]", string.Empty);
|
||||
return _response;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace AdventOfCode._2022.Day7
|
||||
{
|
||||
var root = GenerateDirectory();
|
||||
|
||||
root.Print("");
|
||||
if (!_request.IgnoreLogMessages)
|
||||
root.Print("");
|
||||
|
||||
var allDirectories = root.GetAllDirectories().ToList();
|
||||
_response.Answer = allDirectories.Where(x => x.GetSize() <= 100000).Sum(x => x.GetSize());
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace AdventOfCode._2022.Models
|
||||
{
|
||||
foreach (var move in moves)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(move)) continue;
|
||||
string numbersOnly = Regex.Replace(move, "[^0-9.]", " ");
|
||||
var pendingMoves = Regex.Replace(numbersOnly, @"\s+", " ").Trim().Split(" ");
|
||||
_board.Move(version, pendingMoves[0].ToInt(), pendingMoves[1].ToInt(), pendingMoves[2].ToInt());
|
||||
|
||||
Reference in New Issue
Block a user