From 5513d56c4d3a8f29dc70f44206869dd2b5c71d50 Mon Sep 17 00:00:00 2001 From: Logan G Date: Sat, 3 Dec 2022 19:03:50 -0700 Subject: [PATCH] Minor performance optimization to D3 --- day3/day3.lua | 2 +- day3/day3part2.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/day3/day3.lua b/day3/day3.lua index 779ec5b..e7cd512 100644 --- a/day3/day3.lua +++ b/day3/day3.lua @@ -7,7 +7,7 @@ function find_duplicates(first, second) for i = 1, #first do local char = string.sub(first, i, i) - if string.match(second, char) then + if string.find(second, char) then if char == string.upper(char) then return string.byte(char) - string.byte("A") + 27 elseif char == string.lower(char) then diff --git a/day3/day3part2.lua b/day3/day3part2.lua index af7c405..a3c6601 100644 --- a/day3/day3part2.lua +++ b/day3/day3part2.lua @@ -11,7 +11,7 @@ end function find_duplicates(one, two, three) for i = 1, #one do local char = string.sub(one, i, i) - if string.match(two, char) and string.match(three, char) then + if string.find(two, char) and string.find(three, char) then if char == string.upper(char) then return string.byte(char) - string.byte("A") + 27 elseif char == string.lower(char) then