aoc-2021-rust

Advent of Code 2021 Solutions in Rust
git clone https://git.sinitax.com/sinitax/aoc-2021-rust
Log | Files | Refs | README | sfeed.txt

part2 (1124B)


      1--- Part Two ---
      2
      3You notice a second question on the back of the homework assignment:
      4
      5What is the largest magnitude you can get from adding only two of the snailfish numbers?
      6
      7Note that snailfish addition is not commutative - that is, x + y and y + x can produce different
      8results.
      9
     10Again considering the last example homework assignment above:
     11
     12[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
     13[[[5,[2,8]],4],[5,[[9,9],0]]]
     14[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
     15[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
     16[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
     17[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
     18[[[[5,4],[7,7]],8],[[8,3],8]]
     19[[9,3],[[9,9],[6,[4,9]]]]
     20[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
     21[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]
     22
     23The largest magnitude of the sum of any two snailfish numbers in this list is 3993. This is the
     24magnitude of [[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]] +
     25[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]], which reduces to
     26[[[[7,8],[6,6]],[[6,0],[7,7]]],[[[7,8],[8,8]],[[7,9],[0,6]]]].
     27
     28What is the largest magnitude of any sum of two different snailfish numbers from the homework
     29assignment?
     30
     31