From 3555be54c2abb8d5ece008a60dbdfbde0ffbddd7 Mon Sep 17 00:00:00 2001 From: Alex Pickering Date: Fri, 7 Feb 2025 12:49:48 -0600 Subject: inital commit --- 06/1.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 06/1.lua (limited to '06/1.lua') diff --git a/06/1.lua b/06/1.lua new file mode 100644 index 0000000..68ea3e2 --- /dev/null +++ b/06/1.lua @@ -0,0 +1,28 @@ +require("ext") +local line = io.read("*a") + +local buf = {} +for i = 1,14 do + table.insert(buf, line:sub(i,i)) +end +function checkbuf() + local s,u = {},0 + for _,v in pairs(buf) do + if not s[v] then + s[v] = true + u = u + 1 + end + end + if u == 14 then + return true + end +end +if checkbuf() then print(14) end +for i = 15,#line do + table.remove(buf,1) + table.insert(buf,line:sub(i,i)) + if checkbuf() then + print(i) + break + end +end -- cgit v1.2.3-70-g09d2