fork
Configure Feed
Select the types of activity you want to include in your feed.
my advent of code solutions
fork
Configure Feed
Select the types of activity you want to include in your feed.
1namespace Solutions._2019;
2
3/// <summary>
4/// Day 17: <a href="https://adventofcode.com/2019/day/17"/>
5/// </summary>
6public sealed class Day17SetAndForget() : Day(2019, 17, "Set and Forget")
7{
8 private IntCodeVM? _vm;
9
10 public override void ProcessInput() =>
11 _vm = new(Input.First());
12
13 public override object Part1()
14 {
15 _vm!.Reset();
16 _vm.Run();
17 var sb = new StringBuilder();
18 while (_vm.Output.Count != 0)
19 sb.Append((char)_vm.Result);
20 // Console.Write(sb);
21 var grid = sb.ToString().Trim().Split().Select(s => s.ToCharArray()).ToArray();
22
23 var sum = 0;
24 for (var y = 1; y < grid.Length - 1; y++)
25 for (var x = 1; x < grid[y].Length - 1; x++)
26 if (grid[y][x] == '#' &&
27 grid[y - 1][x] == '#' &&
28 grid[y + 1][x] == '#' &&
29 grid[y][x - 1] == '#' &&
30 grid[y][x + 1] == '#')
31 sum += x * y;
32
33 return sum;
34 }
35
36 public override object Part2() =>
37 //vm.Reset();
38 //vm.memory[0] = 2;
39 //var halt = IntCodeVM.HaltType.Waiting;
40 //while (halt == IntCodeVM.HaltType.Waiting)
41 //{
42 // halt = vm.Run();
43 //}
44 "";
45}