# Day 2: Learning, Testing, and Junior Dev Vibes

It’s Day 2 of Advent of Code, and my AI assistant, Aider (+ Claude Sonnet), is already showing signs of learning and adapting. Today’s challenge was all about parsing and analyzing data, with a mix of predictable successes, unexpected issues, and a sprinkle of junior dev behavior from the AI.

The full code is available on [GitHub](https://github.com/rjNemo/ai_advent_code_2024).

# Part 1: Red-Nosed Reindeer Data Analysis

The **Red-Nosed Reindeer nuclear fusion/fission plant** engineers needed help analyzing unusual data from their reactor. Each report contains a list of numbers called levels. A report is considered “safe” if it meets two criteria:

1. All the levels are either increasing or decreasing.
    
2. Any two adjacent levels differ by at least 1 and at most 3.
    

## **AI Behavior: A Clever Start**

When I asked Aider to scrape the challenge and store it as a file, it surprised me. Instead of copying the entire challenge, it **summarized** the problem, extracting the key requirements and ignoring the fluff. Its output included a short description and an example, which was oddly efficient! It’s learning how to cut to the chase – a promising sign.

## **Red, Green, Refactor**

1. **Red: Writing Failing Tests**
    

Following the test-driven development (TDD) approach, I wrote tests based on the example input. Aider generated:

* Tests for valid inputs to compute individual parts of the solution.
    
* Failing test cases for edge cases like empty input or invalid formats.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733121619737/8b90d518-d7c0-4b81-992a-8ea64a037d7e.png align="center")

2. **Green: Implementation Code**
    

Aider then implemented the code. The solution was surprisingly clean and idiomatic for Elixir. It:

* Followed Elixir conventions and project structure.
    
* Handled all test cases, including edge cases and error conditions.
    
* Broke down the problem into smaller, reusable functions:
    
    * `parse_reports/1`: Validates the input.
        
    * `parse_line/1`: Converts strings to numbers.
        
    * `safe_report?/1`: Contains the main logic.
        
* Used helper functions for checking increasing or decreasing patterns.
    

It even employed the `with` keyword, elegantly focusing the logic on the happy path while bubbling errors up.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733122165518/94353b75-8351-4cab-9e5a-c90f81bb55b6.png align="center")

The `parse_report` function handled errors gracefully

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733122358889/3b8cb23d-cde7-4f09-9dcf-a5ca4684859b.png align="center")

3. **Refactor**
    

There wasn’t much refactoring needed – the code was already better than I expected! It followed idiomatic patterns and was well-structured.

## **Hallucination Alert!**

### December 2023?!

At one point, Aider claimed the puzzle input wasn’t available until **December 2024** (spoiler: it’s December 2nd, 2024). After I pushed back, it acknowledged the mistake and told me to fetch the data myself. Classic junior dev vibes: “If I can’t do it, it must be impossible!”

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733122639620/0d9da10f-012d-4b07-94ed-d6d011442f51.png align="center")

Fine, I retrieved the data manually.

### Wrong Puzzle?!

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733123409572/7986ecce-60c8-4b6f-b874-233fdaa105c4.png align="center")

With the real input in hand, I ran into another hiccup. The AI struggled because the test inputs had uniform rows, but the real input didn’t. This was a case of **overfitting** to the test cases – a valuable lesson in ensuring tests are as generic as possible.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733123415350/43169e51-9927-4c90-922a-d2daf4e28a85.png align="center")

Once I clarified the issue, the AI fixed the solution and apologized. Success! However, it inadvertently broke the tests during the process. After a quick nudge to run the tests during refactoring, it resolved the issue quickly. A good reminder to be explicit in instructions when collaborating with an AI.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733123713209/638cfd51-ef6e-4eba-b2f5-22c9b4633f78.png align="center")

# **Part 2: The Harder Variant**

As always, Advent of Code’s second part added complexity to the challenge.

1. **New Tests**
    

I started by creating tests for the updated requirements. Aider adapted smoothly, generating comprehensive tests for the additional logic.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733124530700/b7615f09-8dff-4b76-a695-70209afde437.png align="center")

2. **Implementation**
    

The implementation phase went smoothly. Aider continued to follow the idiomatic patterns established earlier and handled the new requirements without much trouble.

3. **Success!**
    

The solution worked on the first try. It felt great to see the AI growing more reliable with each iteration.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1733125048186/b4a66a1e-e89e-4b38-9d0a-5590f4651baf.png align="center")

## **Reflections on Day 2**

Today reinforced some key takeaways for working with AI assistants:

* **Testing discipline is non-negotiable.** Overfitting to edge cases can derail your progress, so always aim for generic tests.
    
* **Be explicit in your instructions.** Even smart tools like Aider need clear guidance to avoid breaking things inadvertently.
    
* **AI can be a great collaborator.** Its ability to focus on implementation details lets me stay focused on the higher-level logic and architecture—a fantastic productivity boost for senior engineers and engineering managers.
    

Day 2 was a mix of learning, problem-solving, and junior dev humor. Can’t wait to see what Day 3 has in store!
