advent_of_code_2022

My (attempted) solutions to the 2022 Advent of Code
git clone https://git.eamoncaddigan.net/advent_of_code_2022.git
Log | Files | Refs | README

commit d72cd3ad8036ada77c2b7ddc3fa76d9da2dc855a
parent 62beb1240c46404e269d0578a6ca4d317cf98c5d
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Mon,  5 Dec 2022 21:59:25 -0800

Ok, I made it more "elegant" (took out a loop).

Diffstat:
Msrc/day_6.jl | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/day_6.jl b/src/day_6.jl @@ -6,11 +6,9 @@ example = ["mjqjpqmgbljsphdztnvjfqwrcgsmlb"] input = readlines("data/day_6.txt") function findmarker(transmission, markerlength) - for i = markerlength:lastindex(transmission) - if allunique(transmission[i-markerlength+1:i]) - return i - end - end + findfirst(i->allunique(transmission[i-markerlength+1:i]), + markerlength:lastindex(transmission)) + + markerlength - 1 end function part_1(input)