using System.Collections.Generic;
using System.Security.Cryptography;
public static class Program
public static void Main()
Console.WriteLine("This christmas tree should really be three times taller...");
var sapling = new List<List<int>>
new List<int> { 1, 2, 1 },
new List<int> { 1, 3, 3, 1 },
new List<int> { 1, 4, 6, 4, 1 }
var tree = GrowTree(sapling, height: 5);
PrintChristmasTree(tree);
var sum = tree.Select(row => row.Sum()).Sum();
var answer = sum.ToString();
Console.WriteLine("A nice tall tree! {0} is the correct answer.", answer);
else if (IsCorrect(tree.Count))
Console.WriteLine("Seems tall enough, but looks kinda funny...");
Console.WriteLine("Still to short :-/");
static List<List<int>> GrowTree(List<List<int>> sapling, int height)
if (sapling.Count >= height)
var bottomRow = sapling.Last();
var newRow = new List<int>();
for (int i = 0; i < bottomRow.Count - 1; i++)
return GrowTree(sapling, height);
static void PrintChristmasTree(List<List<int>> tree)
foreach (List<int> row in tree)
Console.WriteLine(string.Join("~", row));
static bool IsCorrect(string answer)
var correctBytes = new byte[] { 0xD8, 0x44, 0x2B, 0xAF, 0x6F, 0x43, 0x7F, 0x1F, 0x68, 0x2F, 0x0C, 0xAE, 0x9D, 0xDE, 0x1A, 0xF2, 0xD3, 0xC5, 0x95, 0xD8, 0x8A, 0x36, 0x97, 0x18, 0x81, 0xD3, 0x6B, 0x30, 0x47, 0x85, 0xD0, 0x1C };
using (SHA256 sha256Hash = SHA256.Create())
var bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(answer));
return bytes.SequenceEqual(correctBytes);
static bool IsCorrect(int answer)
var correctBytes = new byte[] { 0xE6, 0x29, 0xFA, 0x65, 0x98, 0xD7, 0x32, 0x76, 0x8F, 0x7C, 0x72, 0x6B, 0x4B, 0x62, 0x12, 0x85, 0xF9, 0xC3, 0xB8, 0x53, 0x03, 0x90, 0x0A, 0xA9, 0x12, 0x01, 0x7D, 0xB7, 0x61, 0x7D, 0x8B, 0xDB };
using (SHA256 sha256Hash = SHA256.Create())
var bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(answer.ToString()));
return bytes.SequenceEqual(correctBytes);