forked from adventofcode/logan_2022
Minor performance optimization to D3
This commit is contained in:
parent
ae592b71af
commit
5513d56c4d
2 changed files with 2 additions and 2 deletions
|
@ -7,7 +7,7 @@ function find_duplicates(first, second)
|
||||||
for i = 1, #first do
|
for i = 1, #first do
|
||||||
local char = string.sub(first, i, i)
|
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
|
if char == string.upper(char) then
|
||||||
return string.byte(char) - string.byte("A") + 27
|
return string.byte(char) - string.byte("A") + 27
|
||||||
elseif char == string.lower(char) then
|
elseif char == string.lower(char) then
|
||||||
|
|
|
@ -11,7 +11,7 @@ end
|
||||||
function find_duplicates(one, two, three)
|
function find_duplicates(one, two, three)
|
||||||
for i = 1, #one do
|
for i = 1, #one do
|
||||||
local char = string.sub(one, i, i)
|
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
|
if char == string.upper(char) then
|
||||||
return string.byte(char) - string.byte("A") + 27
|
return string.byte(char) - string.byte("A") + 27
|
||||||
elseif char == string.lower(char) then
|
elseif char == string.lower(char) then
|
||||||
|
|
Loading…
Reference in a new issue