Skip to content

sanderslagman/adventofcode2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ„ Advent of Code 2025 - TypeScript Journey ๐ŸŽ„



                                       ;                                                            
                                  .....:....                                                        
                                   .:x;:x+:.                                                        
                                    .+x:+.                                                          
                                    ..:..;.                                                         
                                    ..;x:.:.                                                        
                                ... ..+X;;++                                                        
                                .x+;x:X+x$::..:                                                     
                                  ;$Xxx:x;xxx..                                                     
                               ... ++xxXxx+;;.....                                                  
                               .:X$++;+XX:;+++;+                                                    
                              ....X.$xXxx;++;:+...                                                  
                            .+$$$$xX$$X+X$x;;xx......                                               
                            . ..:$X$X..x$XXx+x$&.......            ........ .                       
                           ..+.&$$xxXXXxxXxxXX.;;;.x+..         .:&XXX:.......                      
                     ...x.&..+$$X+$$$X$.xxXxX:+x:+xX..         .XXX::.......:..                     
                      XX$$&+$$$Xx.:x$$xXx.XX$xXXXxx;...       .XX+;;++;:::;...                      
                     ..:.x&&X$$$$$xX$$$X$$xXXXX$XX:x.. ..   ..$Xx+x:+;x&+:..:..                     
                        ...+&$$&:XXXX$XXXxxX+XxX+.+;;.;;.. .:$$Xx:.;xx$:.;.:+.                      
                        ;X&&&&$$&$XxXX;+XxX++XXxx+++++:..  .+$$$+::.;..;...;::                      
                     ......xX$&$$&$$$X:.++:.:;xx+X$++;;.:....&$$;::.....+&:......      ..XX...+xxxx.
                 .:.:.XX+$$&&$$$$.$$x$$+$+;:;xXX&x$$X$X;+;:x:&&;;:................     ..$X;XXXXXXX$
                 .X$$X;xXx&x.XX&$$&&$$$$&$XXXXx+:+XxXx:XXX$XXXXXXX:........   . ..     .;$XXXXXXX:..
             .xXxXXXx&&X;XXX$$$$$;+$&$&X$Xx+xx+X+;X+X+:$X$&.xXXXXXXX...............   ...&$$$$X$.   
              . :+$$$&$XxXXXX$XxX:x$$$$$x:$XX$x$$X:;$X$X$X.....$XXXX:.:....... ..:.   .....$$$:.    
             .:x+x$XX+Xxx+;x$x$+$$$:XXXXXX$X$+xx$.$:X$XX$XXX....:$$XXX+::.......:XxX. .X....&:..    
        .$.......;+;++X&XXX$$&$$$$&X$XXXXxX&$$&$$+XXX$$$XXXXX....x$$XXx$$;:+:..XXxxXXX;X$.....:;.   
        . $&...+.X.;.$x&$&$$$$&$$x++xxxxxxXX$+&XxXXX$$XXXXXXX$::::$$XXX$XXXXX&XXXXxxXX$$XX:::;;;    
        ...$x$XX.$&XX$&X$&$XXXXX$&$$&$x;+;x$XX++XXX$$XXXXXXX$$$;;;$$$Xx$XXXXxXXXXXxxX$$$$$$$&;..    
         ..:$$$&&$X$$$$XX$$&$;+$$$$&.&$X$X$:$$$XXXX$$XXXX$$$$$$;;;$&XXXXXXXXXXXXXxXXXXX$$$$$&.      
       .$$:X&&&+:&$$XX$XXXX$X&$$x$XxXXx+$$&$$$$XXX$$X$$$$$$$$$$;$$$$X$XXXXXXXXX$$xXXXXX$$$&$.       
        ...XX&$$&&&;X$$$$&X$XxXXx.x$&$XX$XX$XxXXXXXX$$$$$$$$&&&$$$$$$$$$XXXXXXX$XXXXXXXX.....       
        . .X;XX;+&$$$$+$&$$xxXXXXX$$+XXX$X$XxXXXXXXX$$$$$$$&&&&&&$$$$$$$$$XXXXX$$+XXXXXX.           
            :..x:;..&$;$$$&$&X:$+&&$$x$$&&XXXXXXXXX$$$$$$$&&&&&&&$&$$$$$$$$$$$$$$$$$$$$$.           
     ..:.....:X$+x$$$&$&$$$$&$xxXXX$&x$&+x$XXXXXX$$$$$$$$&&&&&&&&$$&&&&&&$$$&&&Xx&&+$$&             
   .;+..+&&$;$+XX$$X$&X$X$&;xx++;x$&&$+$XX$XXXXX$$$$$$$$$&&&&&&$$$&&&&&&&&$&&&&$&&x&&$&             
 ..;x$&$&X.$&$;:.$$$$&x$$$$$$XXXX$$$$$X$++XXXX$$$$$$$$$$&&&&&&$$$$$$$$XXX$$&$X$x:+xXXXx             
...:X;;$$$XX&$;::+$&$$$$$$$X$$$X$+$$$&$XxxX$$$$$$$$$$$$&&&&&&$$$$$$$$$XXX$XXXXXX$XXXXXX;.           
.:xX$&$.;x$$$XXxxXX&&$$&$X$$&&$$$X&X&XXxx$X$$$$$$$$$$$$;;:X&$$$&$$$$$XXXXXXXXXXX$XXXxXXX.           
 . ..;$&&$$;&&$&&&&&&&$X$$&$&&&:+$X$$&&$$X$$$$$$$$$$$$&;;;;;;;;::....+XXXXXXXXXXXxXxxXXx.           
    .......&&$$&.&&$XXXX&$X$X$&$$&$X$$$$x$$$$$$$$$$$$$+;;;;;;;:::........................           
     .&x.;X$$$$&$&XXx&XX&XXXX&.$&&$&$$x$$$$x$$$$$$$$$&&&&:;;;;:::........................           
   ..$$&&$x$&&$&;$X$$$$$&&&&$$&XXX$&$$$X$+X$$$$$$$$&&&&&&&&&&&&::::.......... .........:.           
 .::.$&;.+$xXXx$$$$$$$&&$Xx$$$$$$X$X$:++XxX$Xx&$$$&&&&&&&&&&&$$$$$$XXXXXX&$$$$$$XXXX.               
..+$X&+$$;xX$$$$$$&&$$&+$XX$$$&$$$$&$X$$$X$$$XXXx&&&&&&&&&&&&$$$$$XXXXXXx&$$$$$XXXXX.               
.XXXX:;$$+xX&$$+$&$&&x++xXX&&$X&;$$X$XXX$++X$$&$$$$&&&&&&&&&$$$$$XXXXX:.;&$$$$$XXXXx.               
 ..:+$$$&..x$$$$+.X$x+:+;;$;xX+&$X.+&X$X&&$&$$&.+$$Xxx..:.:$$$$$$XXXX$   &$$$$$$XXX..               
   XX...  ..X&...++. .;XX;X$;;;+.....:$&&&&&&&& . &$$.x...;;$$$XXXXX.x..:.++;.......                
   .       x..       .XXxXx:X$++..Xx.:xX&X&&&$$....x++++.:;;::......   ..;;:::.....                 
                ..  ..XXX..+XX$X+$$x&$XX;;x&&$X;:$$Xxxx+;;;;:::.....   ..;::::.....                 
     ............::;;;xX;:$$$X+xx+$x$$Xx;;x$$$&XxxX$$$X+x;X;:::............$&&&&&X                  
  ...........::::::XX$Xx++X$X$;x;;$x$$xX+;x$X.x&$xX$++++x;;&&&&$:x:::......$&&&&&X.                 
    ..............:::.;Xx+X$XX:X;;$x&x+X$+Xx$$$&&;X$X$;X+x&&&&&$:x........:$&&&&&;&                 
            ....:....:...X:x.:....:+.xX$:;$:XX+.$;:::++..:&&$x&....       $&&&&&&&&&...             
                                               .........;&&&&&&...  ......&&&+&&&&&&&$+             
                                               . .......:&&&&+....    .................             


"'Twas the night before Christmas, and all through the code,
Not a bug was stirring, not even a node..."
๐Ÿ›

Ho ho ho! This repository contains my solutions for the Advent of Code 2025 challenge, where I'm sleighing through algorithmic puzzles one TypeScript solution at a time! Each day brings new coding challenges that would make even Santa's elves scratch their pointy hats. ๐Ÿงโ€โ™‚๏ธ

๐ŸŽ„ Project Structure

๐ŸŽ„ adventofcode2025/
โ”œโ”€โ”€ ๐ŸŽ 1/                    # Day 1: Safe Cracking Adventure
โ”‚   โ”œโ”€โ”€ ๐Ÿ” crackSafe.ts      # Combination lock simulation
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Secret combination steps
โ”œโ”€โ”€ ๐ŸŽ 2/                    # Day 2: Gift Shop Pattern Detective  
โ”‚   โ”œโ”€โ”€ ๐Ÿ” patterns.ts       # Invalid product ID detection
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Product ID ranges to check
โ”œโ”€โ”€ ๐ŸŽ 3/                    # Day 3: Battery Joltage Calculator
โ”‚   โ”œโ”€โ”€ โšก joltage.ts        # Battery bank optimization
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Battery joltage ratings
โ”œโ”€โ”€ ๐ŸŽ 4/                    # Day 4: Forklift Paper Roll Optimization
โ”‚   โ”œโ”€โ”€ ๐Ÿš› forklift.ts       # Paper roll accessibility analysis
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Paper roll grid layout
โ”œโ”€โ”€ ๐ŸŽ 6/                    # Day 6: Cephalopod Math Homework
โ”‚   โ”œโ”€โ”€ ๐Ÿงฎ cephalopodMath.ts # Space-delimited worksheet parser
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Math worksheet data
โ”œโ”€โ”€ ๐ŸŽ 7/                    # Day 7: Tachyon Manifold Repair
โ”‚   โ”œโ”€โ”€ โšก laboratories.ts   # Beam splitting simulation
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Laboratory grid layout
โ”œโ”€โ”€ ๐ŸŽ 8/                    # Day 8: Junction Box Circuits
โ”‚   โ”œโ”€โ”€ โšก junctionBoxes.ts   # Christmas light circuit optimization
โ”‚   โ””โ”€โ”€ ๐Ÿ“ input.txt         # Junction box 3D coordinates
โ”œโ”€โ”€ ๐Ÿ“ฆ package.json          # Dependencies & scripts
โ””โ”€โ”€ ๐ŸŽ… README.md             # You are here! Ho ho ho!

โ„๏ธ Solutions Overview

๐ŸŽ Day 1: Cracking the Safe

"Santa's locked the password behinf a ... password?!"

The elves need help opening Santa's combination safe. Using a series of left and right rotations, we simulate the knob movements and track how many times we pass through or land on specific values.

Features:

  • ๐Ÿ” Safe simulation with customizable parameters
  • ๐ŸŽฏ Part 1: Tracks landing on a given position
  • ๐ŸŽฏ Part 2: Tracks the amount of pass-throughs on a given position
  • ๐Ÿ”„ Handles wraparound rotations like a real safe

๐ŸŽ Day 2: Gift Shop Pattern Detective

"Invalid product IDs are sneaking into the North Pole gift shop database!"

A mischievous young elf has been adding invalid product IDs with repeating digit patterns. Our job is to identify and sum up these problematic IDs across various ranges.

Features:

  • ๐ŸŽฏ Part 1: Detects patterns repeated exactly twice (55, 6464, 123123)
  • ๐ŸŽฏ Part 2: Detects patterns repeated at least twice (111, 12341234, 1212121212)
  • ๐Ÿ“Š Processes large ranges efficiently
  • ๐Ÿ” Comprehensive pattern detection algorithms

๐ŸŽ Day 3: Battery Joltage Calculator

"The escalator needs power, and we've got batteries to spare!"

The underground escalator is offline and needs joltage from battery banks. Each bank contains multiple batteries with joltage ratings from 1-9. We need to select the optimal batteries to produce maximum joltage.

Features:

  • โšก Part 1: Selects 2 batteries per bank for maximum 2-digit joltage
  • โšก Part 2: Selects 12 batteries per bank for maximum 12-digit joltage
  • ๐Ÿงฎ Uses greedy algorithm for optimal battery selection

๐ŸŽ Day 4: Forklift Paper Roll Optimization

"Help the printing department optimize their forklift operations!"

The printing department has paper rolls scattered across a grid, and forklifts need to access them efficiently. A paper roll can only be accessed if it has fewer than 4 adjacent paper rolls. Help optimize the workflow so forklifts can break through to the cafeteria!

Features:

  • ๐Ÿš› Part 1: Identifies initially accessible paper rolls
  • ๐Ÿš› Part 2: Recursively removes all possible paper rolls until none remain accessible
  • ๐Ÿ“ Grid-based neighbor counting in 8 directions

๐ŸŽ Day 6: Cephalopod Math Homework

"Help the cephalopods parse their space-delimited math worksheets!"

The cephalopods need help with their homework - parsing numbers and operators from a space-delimited worksheet format. The challenge involves correctly identifying column boundaries and extracting vertical number sequences.

Features:

  • ๐Ÿงฎ Space-delimited parsing: Handles variable spacing between numbers and operators
  • ๐Ÿ“Š Column detection: Identifies operator positions to determine column widths
  • ๐Ÿ”ข Vertical number construction: Reads numbers vertically from worksheet columns
  • โœ… Math validation: Performs calculations to verify worksheet correctness

๐ŸŽ Day 7: Tachyon Manifold Repair

"Fix the teleporter by simulating beam splitting through laboratory equipment!"

Repair the teleporter's tachyon manifold by tracing light beams through a laboratory filled with splitters and mirrors. The beams split and bounce in complex patterns that must be carefully tracked.

Features:

  • โšก Part 1: Simulate beam splitting and count unique beam paths (Result: 1594)
  • โšก Part 2: Count quantum timeline variations with memoization (Result: 15,650,261,281,478)
  • ๐Ÿ”„ Grid simulation: Track beam positions and directions through laboratory equipment
  • ๐Ÿง  Memoization: Optimize recursive calculations for massive timeline counting

๐ŸŽ Day 8: Junction Box Circuits

"Help the Elves connect Christmas lights across the playground!"

The Elves need to connect suspended junction boxes with strings of Christmas lights. Find the optimal connections to create circuits while minimizing cable usage. The solution uses graph theory and Union-Find data structures.

Features:

  • โšก Part 1: Connect 1000 shortest pairs, calculate product of three largest circuits
  • โšก Part 2: Connect all boxes into one circuit, find final connection coordinates
  • ๐Ÿ”— 3D distance calculations and minimum spanning tree algorithms
  • ๐Ÿ“Š Union-Find data structure for efficient connectivity tracking

๐Ÿš€ Getting Started

๐ŸŽ„ Prerequisites

  • Node.js (v16 or higher) - Santa's workshop runs on modern tech!
  • npm - For managing our magical dependencies

๐ŸŽ Installation

# Clone the North Pole repository
git clone https://github.com/sanderslagman/adventofcode2025.git
cd adventofcode2025

# Install the magic dependencies
npm install

โ„๏ธ Running Solutions

Day 1 - Safe Cracking:

cd 1/
npx tsx crackSafe.ts
# Follow the interactive prompts or modify input.txt

Day 2 - Pattern Detection:

cd 2/
# Add your puzzle input to input.txt, then:
npx tsx patterns.ts

Day 3 - Battery Joltage:

cd 3/
# Add your puzzle input to input.txt, then:
npx tsx joltage.ts

Day 4 - Forklift Optimization:

cd 4/
# Add your puzzle input to input.txt, then:
npx tsx forklift.ts

Day 6 - Cephalopod Math:

cd 6/
# Add your puzzle input to input.txt, then:
npx tsx cephalopodMath.ts

Day 7 - Tachyon Manifold:

cd 7/
# Add your puzzle input to input.txt, then:
npx tsx laboratories.ts

Day 8 - Junction Box Circuits:

cd 8/
# Add your puzzle input to input.txt, then:
npx tsx junctionBoxes.ts

๐ŸŽ… Technologies Used

  • TypeScript - Because even Santa's code needs type safety! โœ…
  • Node.js - Powering the North Pole's computational sleigh
  • tsx - For running TypeScript faster than Rudolph flies

๐ŸŽ„ Code Philosophy

Each solution follows these North Pole coding standards:

  • โ„๏ธ Clean & Readable: Code so clear, even the reindeer can understand it
  • ๐ŸŽ Well Documented: Comments more detailed than Santa's naughty/nice list
  • ๐Ÿ”ง Modular: Functions organized like Santa's workshop - everything in its place
  • ๐ŸŽฏ Efficient: Solutions that run faster than Santa's sleigh on Christmas Eve

๐Ÿงโ€โ™‚๏ธ Author

Fritzo (Sander Slagman) - Chief TypeScript Elf ๐Ÿงโ€โ™‚๏ธ

"Debugging code by day, spreading Christmas cheer by night!"

๐ŸŽ Contributing

Found a more elegant solution? Want to add some extra Christmas magic? Pull requests are as welcome as milk and cookies on Christmas Eve (Or gifts, gifts are even better)! ๐Ÿช๐Ÿฅ›

๐Ÿ“œ License

This project is licensed under the Christmas Spirit License - feel free to use, share, and spread the coding joy! ๐ŸŽ„โœจ


    โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ
  ๐ŸŽ„ May your code compile clean and  ๐ŸŽ„
  ๐ŸŽ…   your algorithms run bright!    ๐ŸŽ…  
    โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ โ„๏ธ

         Merry Coding! ๐Ÿš€โœจ

P.S. Remember to leave some cookies for the debugger! ๐Ÿช

About

Advent of code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors