Skip to content

Instantly share code, notes, and snippets.

@piksel
Last active December 5, 2020 08:37
Show Gist options
  • Save piksel/d7bea4e3c23f67f542256e63ed9fcdcc to your computer and use it in GitHub Desktop.
Save piksel/d7bea4e3c23f67f542256e63ed9fcdcc to your computer and use it in GitHub Desktop.
using System.Linq;
using static System.IO.File;
using static System.Console;
int GetTreeProd(string[] map, params (int x, int y)[] strats)
=> strats.Aggregate(1, (a, t) => a * Enumerable.Range(0, map.Length / t.y).Count(i => map[t.y * i][t.x * i % map[0].Length] == '#'));
var map = ReadAllLines("input.txt");
WriteLine($"Silver: {GetTreeProd(map, (3, 1))}");
WriteLine($"Gold: {GetTreeProd(map, (1,1), (3,1), (5,1), (7,1), (1,2))}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment