Advent of Code: Day 4 (Rust)

Bryson Meiling
Rustaceans
Published in
5 min readDec 4, 2023

--

The Story

We have to help a betting-addicted elf figure out how many scratchers he’s won. He can’t even seem to be bothered by why a human engineer is on his floating island and won’t stop to point us in the direction of someone who can help us. We need some better management around this place.

Alright, this time is a speed run. No more taking forever to write neat blocks of code, check every item, or parse into overly complicated structs. Just gotta do it quick and simple.

These problems are only going to take more time and I don’t want to take up my Christmas season doing silly online coding puzzles… /s

Link to the GitHub

Link to Advent of Code

Part 1: Winning Numbers

Okay, what is the simplest way to deal with this? I think is is to parse the text into two vectors of u32 then compare them. Not too hard.

We are going to:

  1. Split the string by the : and only take what is after that with nth(1)
  2. We need to split the str into two on |
  3. Then we need to split that string on the whitespace
  4. filter and trim out whitespace
  5. Then parse into u32 and collect

--

--

Bryson Meiling
Rustaceans

Software Developer, Girl Dad, Starting a Career in Tech and Exploring all avenues! -> github.com/bryson14