aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/06
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
committerOscar Najera <hi@oscarnajera.com>2023-01-28 03:46:12 +0100
commit84ec86b63ac38423ce021448e379b87094f7d4ac (patch)
tree6574d8b2b5aef30845f38e279a4c389d9fa8897e /AoC2022/06
parent497dc1ea9de502761c00ead6de62abe6eeea67d6 (diff)
downloadscratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.gz
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.tar.bz2
scratch-84ec86b63ac38423ce021448e379b87094f7d4ac.zip
more julia and formatted
Diffstat (limited to 'AoC2022/06')
-rw-r--r--AoC2022/06/solver.jl12
1 files changed, 12 insertions, 0 deletions
diff --git a/AoC2022/06/solver.jl b/AoC2022/06/solver.jl
new file mode 100644
index 0000000..0e3ed39
--- /dev/null
+++ b/AoC2022/06/solver.jl
@@ -0,0 +1,12 @@
+using Test
+
+input = open(read, "input")
+
+unique_slice(arr, i, l) = arr[i-l+1:i] |> unique |> length == l
+
+@testset "solution" begin
+ @test [
+ findfirst(unique_slice(input, i, k) for i = k:length(input)-k+1) + k - 1 for
+ k ∈ (4, 14)
+ ] == [1655, 2665]
+end