Пример #1
0
        public int SolvePart1(string input)
        {
            var lengths = input.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();

            var hash = new SparseHash(this.sparseHashElements);

            hash.Calculate(1, lengths);

            return(hash[0] * hash[1]);
        }
Пример #2
0
        public string SolvePart2(string input)
        {
            var lengths = input.Select(Convert.ToInt32).Concat(new[] { 17, 31, 73, 47, 23 }).ToList();


            var sparseHash = new SparseHash(this.sparseHashElements);

            sparseHash.Calculate(64, lengths);

            var denseHash = new DenseHash(sparseHash);
            var result    = denseHash.Calculate();

            return(result);
        }
Пример #3
0
 public DenseHash(SparseHash hash)
 {
     this.store = hash;
 }