Cleanup code directory

This commit is contained in:
2025-12-01 17:07:33 +01:00
parent 9c258c38ea
commit 637797e349
6 changed files with 3 additions and 0 deletions

20
2025/Day1/Day1_first.lua Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/lua
local Dial = 50
local CountZero = 0
for line in io.lines() do
local Direction, Count = line:match("^(%w)(%d+)$")
if Direction == "R" then
Dial = Dial + tonumber(Count)
else
Dial = Dial - tonumber(Count)
end
Dial = Dial % 100
if Dial == 0 then
CountZero = CountZero + 1
end
print("Direction " .. Direction .. "Count " .. Count .. " Dial: " .. Dial)
end
print(Dial)
print(CountZero)
print("Done")

33
2025/Day1/Day1_second.lua Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/lua
local Dial = 50
local CountZero = 0
local CountClick = 0
for line in io.lines() do
local Direction, Count = line:match("^(%w)(%d+)$")
CountClick = CountClick + math.floor(Count / 100)
Count = Count - (math.floor(Count / 100) * 100)
if Direction == "L" then
Count = 0 - Count
end
if Dial == 0 then
Dial = Dial + Count
else
Dial = Dial + Count
if Dial < 0 or Dial > 100 then
CountClick = CountClick + 1
end
end
Dial = Dial % 100
if Dial == 0 then
CountZero = CountZero + 1
end
print("Direction=" .. Direction .. " Count=" .. Count .. " Dial=" .. Dial .. " CountClick=" .. CountClick)
end
local Total = CountZero + CountClick
print("Dial " .. Dial)
print("Zero " .. CountZero)
print("Clicks " .. CountClick)
print("Total " .. Total)
print("Done")

4510
2025/Day1/full_input Normal file

File diff suppressed because it is too large Load Diff

3
2025/Day1/run.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
cat full_input | ./Day1_first.lua
cat full_input | ./Day2_second.lua

11
2025/Day1/test_input Normal file
View File

@@ -0,0 +1,11 @@
R1000
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82