Skip to content

gvelim/advent2023

Repository files navigation

Advent of Code 2023 Solutions

This repository contains my solutions to the Advent of Code 2023 challenges, implemented in Rust. Each day presents unique algorithmic problems that explore different programming concepts and data structures.

About Advent of Code

Advent of Code is an annual programming event created by Eric Wastl. It consists of 25 daily programming puzzles released each December, designed to be solvable with any programming language. The puzzles typically increase in difficulty as the days progress.

Project Structure

Solutions are organized by day in the src/bin directory. Each day contains:

  • Source code for the solution
  • A README explaining the problem and approach
  • Input data (if applicable)

To run a specific day's solution:

cargo run --bin dayX

Where X is the day number (1-25).

Puzzles and Key Learning Concepts

  • Extract first and last digits from text lines including spelled-out numbers.
  • Key concepts: String parsing, regular expressions, iterators
  • Determine the feasibility of games given bag constraints.
  • Key concepts: Data modeling, parsing, filtering

Day 3 : Gear Ratios

  • Identify numbers adjacent to symbols in a grid.
  • Key concepts: Grid processing, adjacency detection, 2D→1D mapping

Day 4 : Scratchcards

  • Calculate points from matching numbers and track card copies.
  • Key concepts: Set operations, hashmap-based counting
  • Transform values through a series of range mappings.
  • Key concepts: Range operations, transformation pipelines
  • Determine winning strategies for a toy boat race.
  • Key concepts: Quadratic equations, mathematical optimization
  • Rank poker-like hands with custom rules.
  • Key concepts: Classification algorithms, custom sorting
  • Navigate a network following left/right instructions.
  • Key concepts: Graph traversal, cycle detection, LCM
  • Predict sequence values by analyzing differences.
  • Key concepts: Recursive algorithms, sequence analysis

Day 10: Pipe Maze

  • Find the longest path in a loop of connected pipes.
  • Key concepts: Graph traversal, flood fill, even-odd rule
  • Calculate distances between points after space expansion.
  • Key concepts: Coordinate transformation, Manhattan distance

Day 12: Hot Springs

  • Count valid arrangements of springs with constraints.
  • Key concepts: Dynamic programming, memoization
  • Find reflection lines in patterns with imperfections.
  • Key concepts: Pattern recognition, symmetry detection
  • Calculate load on a platform after tilting rocks.
  • Key concepts: Grid simulation, cycle detection

Day 15: Lens Library

  • Implement a hash-based focusing system.
  • Key concepts: Custom hash functions, linked lists
  • Track beam paths through mirrors and splitters.
  • Key concepts: Direction-based simulation, cycle detection
  • Find path with minimal heat loss with directional constraints.
  • Key concepts: Dijkstra's algorithm, state representation
  • Calculate the area enclosed by a trench.
  • Key concepts: Polygon area calculation, Shoelace formula

Day 19: Aplenty

  • Process parts through a workflow of conditional rules.
  • Key concepts: Rule processing, range partitioning

Getting Started

Prerequisites

  • Rust (1.65 or newer recommended)

Installation

  1. Clone this repository
git clone https://github.com/yourusername/advent2023.git
cd advent2023
  1. Build the project
cargo build
  1. Run a specific day
cargo run --bin day1

Acknowledgments

  • Thanks to Eric Wastl for creating Advent of Code
  • The Rust community for their excellent documentation and support

License

This project is licensed under the MIT License - see the LICENSE file for details.