class: center, middle # Chapter 1 - Historian Hysteria  In the enchanted land of the North Pole, the Chief Historian has mysteriously vanished while exploring historically significant sites known only by unique location IDs. A team of Senior Elvish Historians discovers his scattered notes but ends up with two mismatched lists of these magical locations. To solve this festive puzzle, they seek the aid of a talented coder. Embracing the spirit of Christmas, the coder sets out to reconcile the lists. Using his skills, he calculates the total distance between them by pairing numbers and summing their differences, arriving at **1,341,714**. Sensing more Christmas magic at play, he notices many IDs appear in both lists. He then computes a similarity score by multiplying each number in the left list by its occurrences in the right list, totaling **27,384,707**. With the lists harmonized, the path to finding the Chief Historian becomes clear. The elves cheer, the North Pole's festive spirit is rekindled, and all know that Christmas will be merrier thanks to the coder's clever problem-solving. --- class: center, middle # Chapter 2 - Red-Nosed Reports  In the enchanting realm of the North Pole, the coder accompanies the Senior Elvish Historians to the Red-Nosed Reindeer nuclear fusion/fission plant in search of the missing Chief Historian. Though they find no trace of him, the plant's engineers eagerly approach the coder. They reminisce about the time Rudolph was saved through molecular synthesis from a single electron—a legendary feat. Seizing the moment, the engineers ask for help analyzing some unusual data from the Red-Nosed reactor. While the historians scour every nook of the facility, the coder agrees to assist. The data consists of numerous reports, each a list of magical energy levels. A report is considered safe if the levels are all increasing or decreasing, with each adjacent level differing by one to three. Applying his analytical prowess, the coder determines that **624** reports are safe. Later, the engineers recall the Problem Dampener—a device that allows the reactor to tolerate a single bad level in an otherwise safe report. With this in mind, the coder revises his analysis. By considering reports that can be made safe by removing one level, he finds that **658** reports are now safe. Thanks to the coder's expertise, the engineers rejoice, knowing the reactor is secure. The festive spirit glows brighter, and the quest to find the Chief Historian continues with renewed hope. --- class: center, middle # Chapter 3 - Mull It Over  At the bustling North Pole Toboggan Rental Shop, the coder accompanies the Senior Elvish Historians in their quest to find the missing Chief Historian. The flustered shopkeeper admits, "Our computers are having issues, so I have no idea if we have any Chief Historians in stock! You're welcome to check the warehouse, though." The historians set off to search, leaving the coder behind. Turning to the coder, the shopkeeper pleads, "Any chance you can see why our computers are having issues again?" Eager to help, the coder examines the shop's malfunctioning computer. He discovers that the program's memory is corrupted, jumbling all the instructions. The program is meant to perform multiplications using commands like `mul(X,Y)`, but only properly formatted `mul` instructions are valid amid the chaos. Using his skills, the coder scans the corrupted memory to extract all valid `mul` instructions. He calculates the sum of their results, finding it to be **178,538,786**. As he digs deeper, he notices additional commands: `do()` and `don't()`, which enable or disable future `mul` instructions. Respecting these new rules, he recalculates the sum of the enabled multiplications and arrives at **102,467,299**. With the computers restored and functioning, the shopkeeper is elated. The elves can now access the inventory, aiding in the search for the Chief Historian. Thanks to the coder's expertise, the North Pole's holiday preparations continue smoothly, bringing joy and magic to the season. --- class: center, middle # Chapter 4 - Ceres Search  With a flick of a mysterious device, the team is transported to the shimmering Ceres Monitoring Station, nestled among twinkling stars. The snow glistens outside as the Senior Elvish Historians search every corner for the missing Chief Historian. Amidst the magical glow, a petite elf named Lumi tugs on the coder's sleeve. “Can you help me with this enchanted word search?” she asks, her eyes sparkling. The grid before them is a maze of letters, where “XMAS” hides in every direction—horizontal, vertical, diagonal, and even overlapping. Lumi explains, “I need to find all the XMAS instances to unlock the station's festive charms.” With a wave of his fingers, the coder scans the magical letters, uncovering 2,336 hidden “XMAS” spells. The grid lights up, filling the room with joyous Christmas magic. But Lumi giggles, “Wait! It's actually an X-MAS puzzle.” Adjusting his approach, the coder now searches for two “MAS” forming an X, finding 1,831 magical patterns. The station glows brighter, revealing a trail of twinkling lights leading closer to the Chief Historian. Thanks to the coder's cleverness and Lumi's festive spirit, the North Pole's magic flourishes, bringing hope and joy as Christmas approaches. --- class: center, middle # Chapter 5 - Print Queue  The search for the Chief Historian leads the team to the bustling North Pole Printing Department, where elves are frantically preparing the sleigh launch safety manuals. Amid the chaos, a familiar elf waves to the coder, eyes wide with worry. “The updates won't print correctly!” they cry. Without hesitation, the coder steps in to save the day. The manuals must follow a strict set of rules: page X must be printed before page Y if both are included. The elf provides stacks of updates and a list of ordering rules. The coder, with a knowing smile, examines each update, identifying those that are already in the correct order. From these, he calculates the middle page numbers and sums them, arriving at 5,509. But the job isn't done. The coder takes the incorrectly ordered updates and carefully rearranges them according to the rules, restoring order to the print queue. After recalculating, the middle pages of the fixed updates sum to 4,407. With the manuals back on track, the elves cheer. The coder's quick thinking has ensured the safety of Christmas, one perfectly printed page at a time. ---