This commit is contained in:
parent
bf8e77441b
commit
1938202174
|
@ -37,6 +37,7 @@ public class DayTests
|
||||||
[DataRow(typeof(Day14), "5656", "12271437788530")]
|
[DataRow(typeof(Day14), "5656", "12271437788530")]
|
||||||
[DataRow(typeof(Day15), "702", "2955")]
|
[DataRow(typeof(Day15), "702", "2955")]
|
||||||
[DataRow(typeof(Day16), "852", "19348959966392")]
|
[DataRow(typeof(Day16), "852", "19348959966392")]
|
||||||
|
[DataRow(typeof(Day17), "12090", "")]
|
||||||
public void CheckAllDays(Type dayType, string part1, string part2)
|
public void CheckAllDays(Type dayType, string part1, string part2)
|
||||||
{
|
{
|
||||||
var s = Stopwatch.StartNew();
|
var s = Stopwatch.StartNew();
|
||||||
|
@ -83,6 +84,7 @@ public class DayTests
|
||||||
[DataRow(typeof(Day14), "1588", "2188189693529")]
|
[DataRow(typeof(Day14), "1588", "2188189693529")]
|
||||||
[DataRow(typeof(Day15), "40", "315")]
|
[DataRow(typeof(Day15), "40", "315")]
|
||||||
[DataRow(typeof(Day16), "16", "15")]
|
[DataRow(typeof(Day16), "16", "15")]
|
||||||
|
[DataRow(typeof(Day17), "45", "112")]
|
||||||
public void CheckTestInputs(Type dayType, string part1, string part2)
|
public void CheckTestInputs(Type dayType, string part1, string part2)
|
||||||
{
|
{
|
||||||
Day.UseTestInput = true;
|
Day.UseTestInput = true;
|
||||||
|
|
28
aoc2021/Day17.cs
Normal file
28
aoc2021/Day17.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
namespace aoc2021;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Day 17: <see href="https://adventofcode.com/2021/day/17"/>
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Day17 : Day
|
||||||
|
{
|
||||||
|
private readonly List<int> _target;
|
||||||
|
|
||||||
|
public Day17() : base(17, "Trick Shot")
|
||||||
|
{
|
||||||
|
_target = Input.First()
|
||||||
|
.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Skip(2)
|
||||||
|
.SelectMany(i => i.Split('=')[1].Split(".."))
|
||||||
|
.Select(i => i.TrimEnd(','))
|
||||||
|
.Select(int.Parse)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object Part1()
|
||||||
|
{
|
||||||
|
var initialYVelocity = Math.Abs(_target[2]) - 1;
|
||||||
|
return (initialYVelocity + 1) * initialYVelocity / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object Part2() => "";
|
||||||
|
}
|
1
aoc2021/input/day17.in
Normal file
1
aoc2021/input/day17.in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target area: x=94..151, y=-156..-103
|
1
aoc2021/input/test17.in
Normal file
1
aoc2021/input/test17.in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target area: x=20..30, y=-10..-5
|
Loading…
Reference in New Issue
Block a user