Compare commits

..

16 Commits

Author SHA1 Message Date
01d59f641a Day5 Second puzzle 2025-12-05 09:38:16 +01:00
efd650f1cd Test autorunner on Day4 2025-12-05 07:59:37 +01:00
05c49abca3 Day5 First puzzle get 2025-12-05 07:59:09 +01:00
6b90ca82e3 Create autorun script for neovim 2025-12-05 07:58:53 +01:00
d20e87c963 Update Readme 2025-12-04 21:27:10 +01:00
1785bf5038 Day3 second 2025-12-04 21:26:21 +01:00
febe80cfb5 Day 4 done 2025-12-04 08:16:42 +01:00
f159a0fee6 First star done 2025-12-03 08:14:22 +01:00
b2e56c65f5 Remove not needed Makefile 2025-12-03 08:03:05 +01:00
24c2391aea Almost there, commit before refactor 2025-12-03 08:02:50 +01:00
7eee9c6634 Make Lessons default for gitea 2025-12-02 19:53:45 +01:00
c14c4d3193 Fix second star day2 2025-12-02 19:52:52 +01:00
fffa4ea539 Work on Day2 first star, few open issues 2025-12-02 09:11:37 +01:00
30693ed069 Cleanup code a bit and add comments 2025-12-01 17:26:56 +01:00
7fcad7eb85 Update documentation 2025-12-01 17:08:36 +01:00
637797e349 Cleanup code directory 2025-12-01 17:07:33 +01:00
24 changed files with 2098 additions and 4 deletions

2
2025/' Normal file
View File

@@ -0,0 +1,2 @@
-- Using Autorun now
print("Starting Day 5...")

View File

@@ -1,4 +0,0 @@
Lessons from first day
1. Read! Oh that brain of mine, skipping half the things and missing things like count clicks not end point dial
2. Setup a proper test, make a smaller input test that you know the answer to to check the code

60
2025/Day1/Day1_final.lua Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/lua
-- Cleaned up version of my code
--
-- Author: Bas Grolleman
--
-- Variables
local Dial = 50
local CountZero = 0
local CountClick = 0
local Debug = false
for line in io.lines() do
-- Extract variables from line (Lacks error handling)
local Direction, Count = line:match("^(%w)(%d+)$")
-- Count clicks on higher then 100 number
CountClick = CountClick + math.floor(Count / 100)
Count = Count - (math.floor(Count / 100) * 100)
-- L is negative, so make counter reflect that
if Direction == "L" then
Count = 0 - Count
end
-- Touch that dial
if Dial == 0 then
Dial = Dial + Count
else
Dial = Dial + Count
-- Check if dial past 0
if Dial < 0 or Dial > 100 then
CountClick = CountClick + 1
end
end
-- Set Dial within 0-99
Dial = Dial % 100
-- Count 0
if Dial == 0 then
CountZero = CountZero + 1
end
-- Debug Lines when needed
if Debug then
print("Direction=" .. Direction .. " Count=" .. Count .. " Dial=" .. Dial .. " CountClick=" .. CountClick)
end
end
-- Print results
print(
string.format(
"Dial %s | Countzero %s | Countclick %s\n\nAnswer %s",
Dial,
CountZero,
CountClick,
CountZero + CountClick
)
)

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

30
2025/Day2/Day2_first.lua Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/lua
local TotalInvalid = 0
local Input =
"78847-119454,636-933,7143759788-7143793713,9960235-10043487,44480-68595,23468-43311,89-123,785189-1014654,3829443354-3829647366,647009-692765,2-20,30-42,120909-197026,5477469-5677783,9191900808-9191943802,1045643-1169377,46347154-46441299,2349460-2379599,719196-779497,483556-641804,265244-450847,210541-230207,195-275,75702340-75883143,58-84,2152-3237,3367-5895,1552-2029,9575-13844,6048-8966,419388311-419470147,936-1409,9292901468-9292987321"
-- "11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862"
--"11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124"
local DEBUG = true
for CheckRange in string.gmatch(Input, "([^,]+)") do
local Start, End = CheckRange:match("^(%d+)-(%d+)$")
if DEBUG then
print(Start .. " to " .. End)
end
for Check = Start, End do
if string.len(Check) % 2 == 0 then
local mid = string.len(Check) / 2
local first = string.sub(Check, 1, mid)
local second = string.sub(Check, -mid, -1)
if first == second then
print("Invalid " .. Check)
TotalInvalid = TotalInvalid + Check
end
end
end
end
print("Total Count Invalid IDs " .. TotalInvalid)
-- local diff = 1227775554 - TotalInvalid
-- print("Difference with check " .. diff)

72
2025/Day2/Day2_second.lua Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/lua
local TotalInvalid = 0
local Input =
--"11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124"
"78847-119454,636-933,7143759788-7143793713,9960235-10043487,44480-68595,23468-43311,89-123,785189-1014654,3829443354-3829647366,647009-692765,2-20,30-42,120909-197026,5477469-5677783,9191900808-9191943802,1045643-1169377,46347154-46441299,2349460-2379599,719196-779497,483556-641804,265244-450847,210541-230207,195-275,75702340-75883143,58-84,2152-3237,3367-5895,1552-2029,9575-13844,6048-8966,419388311-419470147,936-1409,9292901468-9292987321"
local DEBUG = false
--local DEBUG = true
function debug(displaystring)
if DEBUG then
print(displaystring)
end
end
function checkValid(Serial)
for L = 1, math.floor(string.len(Serial) / 2) do
local SingleElement = string.sub(Serial, 1, L)
debug("Checking block size " .. L .. " " .. SingleElement)
local SerialTest = ""
for B = 1, math.floor(string.len(Serial) / L) do
SerialTest = SerialTest .. SingleElement
end
debug(" Compare (" .. Serial .. ") == (" .. SerialTest .. ")")
if tonumber(Serial) == tonumber(SerialTest) then
debug(" Invalid " .. Serial)
return false
end
end
return true
end
function serialTest(Serial)
if checkValid(Serial) then
print("Valid " .. Serial)
else
print("Invalid " .. Serial)
end
end
function checkRange(Start, End)
local Total = 0
for Serial = Start, End do
if not checkValid(Serial) then
debug(" Invalid " .. Serial)
Total = Total + Serial
end
end
return Total
end
print("## Selfcheck - Valid")
serialTest("12")
serialTest("123")
print("## Selfcheck - Invalid")
serialTest("11")
serialTest("22")
serialTest("99")
serialTest("111")
serialTest("565656")
serialTest("123123")
print("## Get to work")
for CheckRange in string.gmatch(Input, "([^,]+)") do
local Start, End = CheckRange:match("^(%d+)-(%d+)$")
TotalInvalid = TotalInvalid + checkRange(Start, End)
end
print("Total Count Invalid IDs " .. TotalInvalid)
-- local diff = 4174379265 - TotalInvalid
-- print("Difference with check " .. diff)

1
2025/Day2/full_input Normal file
View File

@@ -0,0 +1 @@
78847-119454,636-933,7143759788-7143793713,9960235-10043487,44480-68595,23468-43311,89-123,785189-1014654,3829443354-3829647366,647009-692765,2-20,30-42,120909-197026,5477469-5677783,9191900808-9191943802,1045643-1169377,46347154-46441299,2349460-2379599,719196-779497,483556-641804,265244-450847,210541-230207,195-275,75702340-75883143,58-84,2152-3237,3367-5895,1552-2029,9575-13844,6048-8966,419388311-419470147,936-1409,9292901468-9292987321

1
2025/Day2/test_input Normal file
View File

@@ -0,0 +1 @@
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124

75
2025/Day3/Day3_first.lua Executable file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/lua
-- See https://adventofcode.com/2025/day/3
local DEBUG = false
function debug(msg)
if DEBUG then
print(msg)
end
end
function MaxJolt(Battery)
local b = {}
local firstdigit = 0
local seconddigit = 0
local maxdigit = 0
lastdigit = tonumber(string.sub(Battery, -1))
debug("lastdigit " .. lastdigit)
BatteryNoLast = string.sub(Battery, 0, -2)
BatteryNoLast:gsub(".", function(c)
table.insert(b, c)
return c
end)
for key, value in pairs(b) do
checkdigit = tonumber(value)
if firstdigit < checkdigit then
firstdigit = checkdigit
end
end
local passedfirst = false
for key, value in pairs(b) do
checkdigit = tonumber(value)
if passedfirst and seconddigit < checkdigit then
seconddigit = checkdigit
end
if checkdigit == firstdigit then
passedfirst = true
end
end
if seconddigit < lastdigit then
seconddigit = lastdigit
end
debug("First " .. firstdigit)
debug("Second " .. seconddigit)
return tostring(firstdigit) .. tostring(seconddigit)
end
function TestMaxJolt(Battery, Test)
local MJ = MaxJolt(Battery)
if MJ == Test then
print("WIN - " .. Battery .. " " .. MJ .. " == " .. Test)
else
print("FAIL - " .. Battery .. " " .. MJ .. " != " .. Test)
end
end
print("# Self Test")
TestMaxJolt("987654321111111", "98")
TestMaxJolt("811111111111119", "89")
TestMaxJolt("234234234234278", "78")
TestMaxJolt("818181911112111", "92")
print("# Calculate MaxJolt")
local TotalJolt = 0
for battery_line in io.lines("full_input") do
TotalJolt = TotalJolt + MaxJolt(battery_line)
end
print("Total " .. TotalJolt)

63
2025/Day3/Day3_second.lua Executable file
View File

@@ -0,0 +1,63 @@
#!/usr/bin/lua
-- See https://adventofcode.com/2025/day/3
local DEBUG = false
function debug(msg)
if DEBUG then
print(msg)
end
end
function MaxJolt(Battery, Size)
debug("Staring Battery Check [" .. Battery .. "] Size [" .. Size .. "]")
-- Load Battery into Array
local BatteryTable = {}
local BatterySize = string.len(Battery)
for Cell in Battery:gmatch(".") do
table.insert(BatteryTable, tonumber(Cell))
end
local Digits = {}
local Start = 1
-- Outer loop for Digits
for I = 1, tonumber(Size) do
debug("Checking digits " .. Start .. " till " .. (BatterySize - (Size - I)))
Digits[I] = 0
for Check = Start, BatterySize - (Size - I) do
if Digits[I] < BatteryTable[Check] then
Digits[I] = BatteryTable[Check]
Start = Check + 1
end
end
end
return table.concat(Digits)
end
function TestMaxJolt(Battery, Test, Size)
local MJ = MaxJolt(Battery, Size)
if MJ == Test then
print("WIN - " .. Battery .. " " .. MJ .. " == " .. Test)
else
print("FAIL - " .. Battery .. " " .. MJ .. " != " .. Test)
end
end
print("# Self Test")
TestMaxJolt("987654321111111", "987654321111", 12)
TestMaxJolt("811111111111119", "811111111119", 12)
TestMaxJolt("234234234234278", "434234234278", 12)
TestMaxJolt("818181911112111", "888911112111", 12)
--
print("# Calculate MaxJolt")
local TotalJolt = 0
--
for battery_line in io.lines("full_input") do
local Jolt = MaxJolt(battery_line, 12)
print(Jolt)
TotalJolt = TotalJolt + Jolt
end
print("Total " .. string.format("%18.0f", TotalJolt))

200
2025/Day3/full_input Normal file
View File

@@ -0,0 +1,200 @@
4641144244413454444424423342544444342452422334233433444444444433441244134444334334433442445541322435
5342626167342261132346432442524535654423854254336833422424525424435362223322423132824617223244222225
3253334325533334343444454444442443343414632433443453434442224354345345354343441443342335732424432245
3125446612343355332433423331342424233221222225351166255322343613238264323364224521414453421341322224
2121433222266221212226223214126322122225222122223232323222232233312272221123232322722362212224321232
3121322293422231222244623232221222322121212124223222342233242161322222432232312232333313222241321233
4343754227224325253462446556234242222265733234423352446126333232224344222242521432311226462243124235
4233945333453333467353542374532527553254345354954353465352433265644455345335344463341137496652164734
5453756862345874845337376263545357351615334758525567326257773648575775767585536364536457521766556466
2222222212232112223311223212222332222242322223221222322113223212222232211222222231322222222222212232
4537238344323323433433332147415344474344425443428332334224283953345235535334544444343254334544255333
2143543142143143543244334242444244354323333433444343644323444214243834442444343543343424434254224333
2123422324333221224222222322222212322323431212212412323224713225222221321222412132643142333221212222
4373537335231321222338473333545357342341653434553573323656422465333333465536523532222237343573233563
6123352252421943254535246241522221345233472743222433674123453212332532244265274234273422332224263312
2535233336222312532242332325224732133222333223243413323239331232214333332351552313324282322325332362
3236333333311222323153263343432221225242232323212223323323233322331133332343312224132225422332323332
2212222322142221222224122332221223123122122322122222242224412532621212122222221212312223114263222222
2323151222322222233332132223321222222252322222222123312222122212232223124421133223224212342122313212
2825122213232222222222222123122222223123223521225122323163322323232132422213311212222243321422222223
2445743737443564743743534553443454433955333356653437463535544454347526174237772454455234424374525245
4242441564243344454434342444351544332335424834464524331444422343463532444442343344333343143234525233
3366353344253533234354545453335544433213366333586364433633333632333456642555234465343336336433652636
1122324322322222223232222221112112212223113662422232221222312223222232132241262232321222262222121423
1112221214421141412222222421213221431223421242244324222232252311132323432222213212222222214249248251
2221122223322222222332211222115322111222122422242121223322222232222222222221212145233123222232321322
4323221222232233232123222222222243125522232122322623153221235222381233122224322242213814242212231242
5122222222222125224123222214522222221212212222222214326226221233225212221222542112222652222232221422
2532223349524332222462322324333353433132344233332214213441433223633433231228233253442323231635354542
4224434153715233541233452122414221122442223411522251125334261222111131124243114432222322221322512253
2443543334534345334434264442543344333444336564343422345442452934543544555554534345545354323244245333
2363333526325434537123443333333353236423354432835385614333623637382263533333525364554339333435323334
2439645733422423655745832433374383282342333232123812373236212443513241234422753353338952223333362553
2223522222126221322233322122122232222232123222222313322212332311222211122233222122222222222233222321
2432662444464224354444354342243433342434454445322441445424444543444344454244433354232354324437336535
2422512512422222222122645212211422222221211221222222212321221222122222221212211222212321324222222323
2462312222312329247147222222223321241147212251341542222335435222233262245251342312672234224222222232
2123222362232332322112112272313223513221222523221123222212333273371122242232313223121333322471263223
5122223526243212232232212224313253532252332332323537321341232172413333222722322532233222122233163734
2355476445226532225533545756354354585446246555792493655554468446644665655642444275768444446787554565
7373449743336443522643362348744297866766442348366662335742564834664546532533496534438434643923554325
4355523434433513333524443645535353554334234342544445642353343435436355345444352543425453545523544344
3342344434324334323423333336233433454433433332433143436451544123334534234333333426344833233433233332
3564334544241312545445333623535263624124662354834262553443435453221534347442771465246232454554115533
2211222222222222222121742222222142222121212222112222222422351128222222292222321213262221322122142222
3222314323131431333226222131222233123322422232225353443233222222434242133222322225222214226322222123
1222222226832143222145422222222122222322232222224322223211124424612222322227122222422422322123223223
2124325455624362243313233213454442152222312153133251413331122514663232535534122269442321242362454472
2162222312322222524422492322234366242322343244432422274224242224633122222222233224222222232222223431
3322435534358344423545443434544344434243443424444434462123424444383243284445344322331345424434332343
2122228321121522238221232222152232127322224132222221262222112212122222215223723126222222221222223125
4213225225672442372625624535222555466336731555433664244633543565452245466232251354655233252455423542
3342121526554224232225222223232512225552422442222435124212862212582222112222744824226253522272252249
4411443574742543934434413433443557552445243453424324236846542983345544444355364344552443525225324335
5293421327333637256382343721348937383482346333643333744233541123328534433266456335423433373233543335
3272642252282329772421221553225368223218231743222471242546212223339612421221139241445526244535222822
4213322644541255537649246247534943258424423474657241244243144335334946464462352986432257425323524443
2528423242272255222323434762334222322441214453234215622133122274463952155334633224346311532444534112
1232223243422212122113422212125222222212341312241132222132122222212222222234224232413422312232222133
2442266322845246444683524642643633622616637465936243464634323346454458425645366324355853586768313486
3313322232335142323313222343234324325332322321232342223214326945352415214313342442313162134544143523
6265531262221424122222122224212562243225222626222212321122132125521227222412222511221122122652214252
4362346514214223642415448444254524317322252323224244255254221223152244215251122222322522222625522412
4424316241216414215356512133566264653553156563455656316311365445646266445512626661141125531434146789
2882858546334499442384231783584995332246312589824731334368492741673426328355383233572933284351393533
2211222213222226423642223222243321322412632223123232224114223229222232232313336252353534222232526533
2232222124422124241232221551222252222222232212242512422321432222512228211226212325462546523822234222
4423343343333513152332222235523732133615232432241522324235243622237384172615235232921177522522334424
4433333244546235543453343355373424234444465134345443554411233433444346732342434243435545343455633552
4353355235643466564243644544566546556344434654333444443654664444564354572554444463444542565466547456
2222222227322212222123612222223123221221222522122223222214522123233221222222221221222222222221212122
7222472459425143232164222221214424412242849444232273413453325342742362242121223522433242322333224222
5332442223335541332353114141462423532313132435124212223355225422235515134222553652244534232324735562
1422555384252412242463254554444436324455372714424434452454495543544559964453445356536554544779133455
3444293454448444843454543344434346445444433834343426544344364543454544444443444464544444331544344455
2325463233333333316244452243536636336443412221333222354122243658523132338423122443156712222433431343
4222214222252112227223222322342282242321214342411121352532242112242254322122112422221221421232222412
3556834522355553454438655387254556364344354442965955459465655459755552962934935244644675585723953454
3393333364479397686613534436359341789353233643336156315943351152935642362338342552924332335213574485
3636373533342433563234333333345233362343341332343363364312723243336321335534644673343335323533632643
3133323313323242232223222324823122131434232221323222122133322221243253232134122323331313333323323233
5447554522425252342233347255542655433422523444652453234554314125642222445233326337845443354354456442
3831453237543434321333433444335336432323783433333333434431453336324444334321434433434432433233333443
6736554186426644253377375534745356563565716462657553565517768567535546767744566652767553256743354764
1221321222122312211221223322222222112224122323211222222123222112223222222232323223221312222222223232
3444833334244643361444433414544454242444173276433323633444443323374464733544349653641314363263534321
4452372323353432333322343333523223332323232232323232543431433354333432334323516522533133532273323434
8558697778663439873617598567663778276867763424687666484632554868767636544866684755549344165667673565
4363632321153422343243222542135234322522365566255322526233215165663114362232532553236224629422415332
3364354223224736522526666423153666385335645623423755278236365266432365445363864623424762322721465243
2334341215237332333333335254738263452153322233333233424333242422352423524215374322333417343323433321
2232422333382312443223221112312123122423126233433234322123524267252222522232242382262332523322373452
3133334422343132223332432333323223223332223322723343523256443342433333223343333343333353232433531443
5121324523832277111232258213731673422843242212823251332464757246537422243322224721122442427283613522
6311333342633582533333333283243323333277333331353333632413338354573524353532372332533332422533323232
2837527223537266322783424363764747147226145457525763437625253385226732671272128646272716726637143763
3333232332322323233333353333233333233333333233232233333541633331333533322333633352333223233333213333
5545238824365423231236545142566244466647343624623334474358652326649445442312222921649765133253525693
2332421352221241224122444412262232123122431424321232142328245422222522442311323161217223411412544438
5524636253656234267335431337343446446465264545543485347352324674445439732643661455451546435624228544
5344335233433232343223323333334372234532512325233332233323323323333332223323422322213433244231221422
8253534624242186724231322134324225642853263321127274167744333242332323322445442223622233443261222222
2222225211222222722222222222221712211212222123422232222142222221222112223221221212222163222131122212
3234452243432414252332524344434422442442222443234432432243351445543255333211343242413324552323442313
4363353475487842942643262378643649353334476655248673934325788173238437836383832566854233833357431159
3333363333333443315323333332332333333323424222133333333533333363334334243333423333333533233333333313
1222122422322122226122411222122224212612321233524223222112422221232212322242214222228222222422121222
2122322232241328316222312223222122321222223223223222393223222222216312322242322223722212232222232232
3236445364463433335383366344322232233445423532434224333533453453335363838335332326226343233246234333
5743322653372334763237424542237545262332657577343314227364722526242634373358122427425236314246576726
2232252425152534124242244426622622214634622245412624613231623326365522225226224422364213241231442526
2333225132223533641323243132333124333223734534322144343124232322433354222451413332244232323433312324
4212422222212322325451322332122522215234112323422155241224542214382253522212441224322222423241432313
8224263242213362233443152453322222222231334221223141224412232212262241412423233111422253141222244432
2444142423533635562333274453344732422243132234261922284244632224252241527213222225333726222423443253
2332313431223322333343223322333333222332231332113233333221321232223322322326622333232232224322222232
2325221242223443334153422225224122442244241234542242342324322322423342223353221521234322412451522133
2242622233222242242235231324324245232424432225233222232245123424311123132223213231324341252235212222
3125222234343434422344433733413234333322333652214335321335333213333334372232243313333433322332636131
4724242132173428332345773234312628223312224375222333212222324323113122324233322121322522331112543232
4513343222231233222334335332332421243344242223334544312353333133342233335534323233432322323145323323
9323323563272443336734722433366543333343335332725533373322322433263323333343313235327353644723338253
2323452462258322354212432321532222522521222224563122223242512355342322233212245243345422245566224114
9233233623333593333223243381332353413733554365733623833523334392334723643335353362836333633733833123
3244122353454233333323424322322327442421253552312113324443334322534323312322251253251422222365322443
3334333334633333333643433433333543233233322433335223237532432343337232223333333332323813433333332323
3553455657646654697475355552533548365855538558345464566577863595499296456852785458333475523233555845
2822221522122241222233232222222122221222222223221541222111123235222221612222241212221236221122512145
5242353914324342322464445345855321334534332674533534443633334696533236555213534953333522322335332343
2365325434246335363235331228463732643222643364635333232367334533333745233316438347233455333343239238
6437232453221233322331326231432223323332333432232332323333332332322244433313233262133343233312332334
6221212242232233212222224232112212211262411632512231222271224222123331233222223222225232222212122312
2232233234222112222222222221212223311212221111523222924212221212222121212221422222213222121223224233
6655755543524646845626957366662755334544946516552485374645342947357589841324245535558462624843224337
1212323322221222122232221212224231322222322211212212212222222222221212122221222122215221322221222222
1422244312522222532213211222221124122222222222326862522522354121212232215221224324231223223322252223
5553313335545573235555536556554534725225534573474345335354349473754454433755334332373443333634568143
2724443163242552233263712414252222442253722655227357362325261236323211855153313162144673135232221622
2211222222222222211222313222223422222243321121223222212122232222211212222231222222212222122211222222
1524445222545824253552234224162222243323144243446526711242411346265421535424234333625223652652211422
2512574375232132252577321125315232833232439436233643533239352233222235422223423215227226433222412315
3521343454242334454235244136422332441454233424143232243233243233132434333243234433434313424435333342
4241443734444363444324344344353244443344474333441545553433343464423254424444353444444454444154914462
2422522313236422152134532223213123423432312222311224322211232333251321324242771722243272222332426224
6535225123525455442224414223622334413212232363222328664453332333623552815253343152244224225343542354
4154352542334352546154344441364555524652734456334152353441435553334444424171655524455381372432442144
5463433333324423435425554243353442235422445432652535344345423446234232312241153345343521444232262553
5874536553556462456925656542446535455539843548256553366535534545563752564543356246536544653457654373
5515243429442364454455253434543544243124141443434442434233654432344245444473444363334472342234223435
2552663486323751657384665359573246422645445554673552555548565576465445979625576264426427636554454533
4624643622223234234542222542753452333512524623657153225633225526622322724262214454527749826333242434
4244555433255443442332234245442326322464243232355352252142225435325434535472352323266324533325525232
2924236434273323225252393221121323222649432242434723242332323344333222444433442222822242276321533322
2432154525334152255354534335633322327325453363333628225315345454322243432223233254324335324483132265
1232332222232322235533312531123453252121311252212121222232455323452525834225223222325323214562322112
3212344292433232112233312242232322223236316622513342442323245331437322133232222322343124332271521222
2212312232333322432232212322223323233332312353332242333211222322323352213132231233233333531222231241
7566938564535544427676353796586244266646551126495968641558263448243654664896951296268326223553633456
4643152253655523374454334445324434444544445245773425544333525634554233349429454443444344429554443454
2234223224452322214322523247361115226233434642132455521459463223442126144429421222221112422221245221
2342221144322432443322432223124444513232342224223234523323434353422323432432432242344343331413233432
5144325127224334344523322213233322353225252163225442352332424232341255321424333514443242242435241632
1222232132123223232222223321322212133112133211212222312223421222222222222242212236223222312231333312
6222122224213224621222222222422722222722114221232321222251271222623252622162222232222122122212226222
2343124121222241462122445342232424234516342123242421332527536371414735222641114325222544222572237143
3132223432133532113222224532424281332228231222433234392214324732233212322321222234323213131533522371
2222482168223322122232221222224512232722222713231342225134115266142222213224352445241212252123324222
4653343672652345652446445444463655356425653644452344475263656322635542545325436642535434567747425165
1512131353255454452253313245145125321212225554355335543551152211343321241324214251443153122523336789
4542233444344444325243544533543533536221553243311424142353342322345344145243245352241454523323344332
4233222523323332323421234722133524422254123422324332353432632232233433222433445444322521257323122224
2243222522422243331424132223244221252122452232212244154422221446542322322327242422222221562125545672
5552533323128334733354733251353353496342333335324232227343547463277316173333343743334641538235133336
5241445544532472451322543452326434244421274243442553354323234433243423364412423344343243143733454533
2653264644452325356755223123482453453434332254311241524433328456237244335444122444236254353465444244
4324542342324238115263422332323232424224424121424241282144223242222232222244243212242222143314453443
1111211521221622222222222212224222325252264241222214422252622232612323223212123421244231222232212122
2152442222221213114153512224748422227642237241532243233642457173321224215244774621415223223327312243
8338575527445534554453353555434184556155535444551544335726435555544544654555555577363534351435557544
3233624233394342443442473453433432224423447246334442319132143222624224369424225342143437122435312544
3232323322362233447532222343322322333112123122223223352222212321231223232223333322313332323123332243
1214483763244715345767214456231422126272334247275584353585561686273137148613173382768256346831175529
4331113332444344343123231314442132411211231223114332221342321441242242311321313224441221413142356789
7874687656557157565344687794645787673747327685656787578856467697558465245457654675636758788555585845
6121641222246282475232225223223221462237626227264272372132222622221556233321223225332221425122232622
3563133423222233223333254324332321222713233232333233348323238323233313332552234225233222233323233323
3641124522716243444254122252725312942339454212551129693226417322514222472543243224224253323336239153
5453553334526442335464656553566356345522534463556654344553643524666264565332456542213554595468352624
2324422233223252254624112233432222222222232423441224244221222442433222234232212532413223323222325213
5144231222332223222223221222251321423123122322126426232326322132644134323312312211323521732232323142
4542242222223222245242341322245223243222245212212242441223122341272542232122513434222242223411323142
3424626122767313615767155612327526555664333122213711236537637743351166314144615142642535612364143289
5533233333252463243535424444343336344534463465323552535323234432365123334253343536532544333434263433
1233234323233322223333332332222232332332233227658351322323323323324222132321331331334232332321322322
1322222231242212221132122321212122223211432213212221212222322222322242134122142233222222222212112113
1423227252272621526413321222372262716572245627222222722214322422296247222255222727152334227522435572
4327443522448244242543423343442232454443444634341446443444444346542343543833444445134545447763234442
4323333553233332233243222332353252323223222213341412222313322255533333233323432311253333421353333332
7433384734436364342237476254418424144144346647924444342446548344343224336344333444345733475294534354
3222512323622425223322562322134722122131422232112272412232462322223422252215126343354353937233529334

4
2025/Day3/test_input Normal file
View File

@@ -0,0 +1,4 @@
987654321111111
811111111111119
234234234234278
818181911112111

108
2025/Day4/Day4_first.lua Executable file
View File

@@ -0,0 +1,108 @@
#!/usr/bin/lua
--Advent of Code - 2025 - Day 4
--
--https://adventofcode.com/2025/day/4
-- Problem, find space for forklift to move
-- Tasks
-- [ ] Load Paper roll in array
-- [ ] Walk through Array finding spots
--
--
--local input_file = "test"
local input_file = "Day4/full"
local warehouse = {}
local row = 0
local col = 0
for line in io.lines(input_file) do
row = row + 1
warehouse[row] = {}
col = 0
for location in line:gmatch(".") do
col = col + 1
warehouse[row][col] = location
end
end
function space_for_forklift(warehouse, x, y)
-- I'm making the assuption here that all rows have the same columns
-- normally I would say write a selfcheck to confirm input is sound
local rows = table.getn(warehouse)
local columns = table.getn(warehouse[1])
local spaces = 0
if warehouse[x][y] ~= "@" then
-- No paper roll, so skip
--print("warehouse check " .. x .. "," .. y .. " no paper roll")
return false
end
local freespace = 0
local rolls = 0
for rowskim = -1, 1 do
if warehouse[x + rowskim] == nil then
freespace = freespace + 3
else
for colskim = -1, 1 do
local w = warehouse[x + rowskim][y + colskim]
--print("checking " .. (x + rowskim) .. "," .. (y + colskim) .. "=" .. w)
if not (rowskim == 0 and colskim == 0) then
if w == "@" or w == "X" then
rolls = rolls + 1
else
freespace = freespace + 1
end
end
end
end
end
if rolls < 4 then
--print("warehouse check " .. x .. "," .. y .. " found space")
warehouse[x][y] = "X"
return true
else
--print("warehouse check " .. x .. "," .. y .. " no space")
return false
end
end
function remove_rolls(warehouse)
local maxrows = table.getn(warehouse)
local maxcolumns = table.getn(warehouse[1])
for r = 1, maxrows do
for c = 1, maxcolumns do
if warehouse[r][c] == "X" then
warehouse[r][c] = "."
end
end
end
end
-- print(space_for_forklift(warehouse, 1, 1))
-- print(space_for_forklift(warehouse, 1, 3))
-- print(space_for_forklift(warehouse, 2, 1))
-- print(space_for_forklift(warehouse, 3, 7))
function countrolls(warehouse)
local maxrows = table.getn(warehouse)
local maxcolumns = table.getn(warehouse[1])
local forkliftaccess = 0
for r = 1, maxrows do
for c = 1, maxcolumns do
if space_for_forklift(warehouse, r, c) then
forkliftaccess = forkliftaccess + 1
end
end
end
return forkliftaccess
end
totalrolls = 0
for I = 1, 100 do
cr = countrolls(warehouse)
totalrolls = totalrolls + cr
print("Loop " .. I .. ": " .. cr .. " Rolls removed")
remove_rolls(warehouse)
end
print("Total rolls removed " .. totalrolls)

135
2025/Day4/full Normal file
View File

@@ -0,0 +1,135 @@
..@.@@@...@@@@.@.@@.@.@@@@.@@@.@@@..@@@@@.@@@@@@.@.@@.@..@@@@@@@.@@.@@.@@.@@@...@@@.@@..@@@..@@@@@.@@.@..@.@@@@@.@@.@@.@@.@..@.@.@@...@
@@@@@@@.@@@@@@@.@.@@@@@@@@@@@@@.@...@@@@@@@@@@@@.@..@@@.@@.@..@@@@.@.@@@@@@@.@@@.@@@@@@.@.@@@@@@.@@@...@@@.@@@..@@@@.@@...@@@@@@@@@..@.
@@...@@.@@@@@.....@@@.@.@.@.@@..@@@@@..@.@.@@.@@.@@@@@@@...@.@@..@@@@@@@@.@@@..@@.@@@@@.@@.@.@@@@@@.@@.@@.@@.@..@.@.@.@@.@.@@@@@..@@@@@
@@.@..@.@@@.@@@...@...@.@@@@@@.@@@.@.@@@..@@@..@@.@@@..@@@@.@@..@@.@@.@.@@@@@.@.@@.@@@..@@@@@@@@.@@@@@@@....@.@..@@..@@.@@@..@@@.@.@.@@
..@.@@@.@@.@@@@@@@.@.@@@.@@@@.@@.@@@..@@@@@@@.@@..@@@@.@.@@..@@@@@@@@@...@@.@@@@..@@@@@.@@@.@.@.@@.@@@@@.@@.@@@@.@.@@@@.@.@.@.@@.@@@@@.
@@.@@@@@@@@.@@.@....@.@@@.@@@.@@@..@@.....@@@@@@.@@@@@.@.@@@@.@@..@@@@@@@.@..@@@@@@@@@@@@.@@@@@.@...@..@@@@@@@@@@@@..@@@@@.@@.@@.@@@@@.
..@.@@@@@.@@@@.@@.@@@..@@@@.@@.@@@@..@@@@@..@@@@@..@@@@..@.@.@@@.@@......@@@@@@@@@@@.@@@@@.@@@@..@@.@..@@@@@@@@@@@@@@@@.@..@@@@.@.@@.@@
@@@.@@@@@@@@@..@@@.@@@..@@@@.@@.@@..@.@.@.@@.@..@@@.@@@.@.@.@@@@@@.@@...@.@..@..@@.@@@@.@@@@.@..@.@.@@.@@@..@@@@@@.@@@.@...@@...@@@.@@@
@..@.@@@@...@@.@.@@@@@@@@@@@@..@@@@@@@@..@@...@.@@@@@@@@@@@@.@@.@@.@@.@@@@@@@....@@@@@.@..@@.@@.@.@@@.@@@@@@.@@..@@@.@@@@@@@@@@@@.@@@@.
.@.@@@.@@.@@@.@@..@@@@.@@@.@@@@@@@.@@@@@@.@@@.@@.@@...@@@@@.@@@.@.@@@@@...@@@.@.@..@.@..@@@@@@@@.@.@...@.@@.@.@@.@@@@.@.@@@@@@@@..@@@@@
..@@@.@@@@@@.@@@@..@@@@@@@@@@@@@@.@@...@@@.@.@@@@@@@@@@@@@..@@@.@@.@@@@@@..@@@.@@@.@..@@....@.@......@@..@.@@..@@@@@@.@@...@@@@@@@..@@@
@@.@@@.@@.@..@@@@@.@..@...@..@@@@.@.@@.@.@....@@@.@@.@@..@@..@@@@...@@@@@.@@@..@.@@@@..@@@.@.@....@@@@@.@@@@.@...@@@..@@.@..@@@..@@@...
@@@@.@..@@@@@@@@@@@..@.@@@.@.....@.@@@@@@@..@@...@@@@.@..@..@@@@@@@.@@@@.@@@.@@@...@@.@.@@@@.@@@..@@..@@.@.@..@@@.@@....@@@@@@..@.@..@@
..@.@@.@@@@.@.@@@@@@@.@@@@@@@@@..@@@@@@@.@.@.@@@.@@.@.@........@.@...@@@@@.@@@..@@.@@@@@@...@@.@.@@.@@@@.@@@@@.@@@.@@@..@.@@@.@.@....@@
.@@.@@.@@@@@@.@@@.@@.@@@.@@@@@@@.@@@@.@@.@@..@@@@@..@@@.@@@@@@@@@@@.@@@@..@@@.@.@@.@..@@..@..@@.@.@.@@@.@@.@@...@.@@@@@@@.@@@@@@@@@@.@@
@.@@@...@@.@@@.@@@@....@...@@..@@@@@.@@@..@.@.@@.@@@.@@@@.@@.@.@@@@.@@.@@@..@@@@@@@@@@@@@...@@..@.@@.@@@.@@..@@..@@@@@...@.@.@..@@@.@@@
@.@....@@@@..@@..@.@....@.@@@.@@...@@@@.@.@@@.@..@@@@..@@@@@.@....@..@@@.@@...@.@@.@@@@.@@@@@@@@.@@@@.@@@@@@.@@@.@@@@@..@@.@..@@@@@@..@
@...@@.@..@@@@.@.@..@@.@@@@...@@.@@...@@@@.@@.@@.@@@..@@@..@@@@@@@@@@@@@@@.@.@@@@@@@@@.@@@@.@@@....@@@...@.@@.@@.@.....@@.@.@@@@@@@..@.
@@@.@@@@@.@.@.@@@...@@@..@@@@@@@..@..@.@@@@@@@@@.@@.@@..@@@.@@@@@.@@.@@@..@@@@..@.@@.@@@@@.@@.@@.@@@@@.@.@@@@.@..@@.@@@@@@@@..@@...@...
..@..@.@@@.@@@@.@@@@@..@..@.@.@@@.@@@@.@@@@@@.@@@@@..@@@.@@@.@@@@@@@.@@@@.@@..@.@@@@.@@@...@.@.@@@@@@.@@.@.@.@@@.@@@@...@@.@@@..@@@@@@@
..@@@....@@@.@@.@@@.@@@@.@..@@@@......@@.@@@@@@.@@..@..@@@@@@@@.@@@.@..@@@@@.@@@@.@...@@..@@.@.@@@@@@.@..@....@@@.@@@@@@.@@@@...@...@.@
@@.@@.@@.@.@@@@@@@.@@@@@@@@@@.@@@@.@@@.@@@@.@@@@.@@.@@.@@@@@@@.@.@@@@@@@.@.@@@@.@@@..@...@@@@@@@@@..@@@@...@@@@@@@.@@@@@@@@@@@@@@.@@@@@
.@@.@@.@.@@@@@@@@.@..@@@@.@@@@@@@.@@.@..@@@@@@.@.@.@@@@@..@.@.@..@@..@@..@@@@@@@.@@@..@@.@.....@@........@@@@@@@@.@@.@.@@@..@@@@.@@@@.@
..@@@.@..@@@.@.@@.@@@@@@...@@.@@@@@.@@.@@@....@.@@@@@..@@@.@@@...@@@.....@..@@@@@@@@@@....@.@.@.@@@..@@@.@@.@.@.@@.@@.@.@@...@@.@..@@.@
@.@..@@.@.@..@@@@@@.@@@@..@...@.@@@@@.@@@.@.@@@@@@@@@@@@@@.@@@@..@@.@@.@.@.@@@@@.@.@.@...@@@.@....@.@.@..@@..@@.@..@@.@@.@..@.@@@@@.@.@
.@.@.@.@@..@@@@@@@.@@@@@.@@@@@.@@.@.@@@@..@@.@@@@.@.@@@.@..@@.@@.@.@@@.@.@@@@.@@@..@@@@@@@.@..@@..@@@@.@@...@@@@@@@@@.@@@.@.@...@@@..@@
@@@@@.@@@@.@.@@@.@...@@@.@.@@@@.@.@@@@@@@.@@@..@@.@@@@@..@@@@@@@@@@@.@.@@@..@.@.@@@.@.@@.@@@..@@@.@@@@@@.@@@@@.@@.@@..@@@@@@.@@.@@@.@@@
@.@@@.@@@@@.@@.@.@.@.@@@@@@..@.@.@...@.@@..@@...@@..@@@...@...@.@@@@.@@@@@@...@...@..@@.@@..@@@.@@@.@@.@@.@..@@.@@..@@@@@...@@..@@.@@@@
@@..@@.@@@@@@@...@....@@@@@.@@@...@@@@.@@@@...@@@.@@@@.@@..@@@@..@..@..@@@@@@@@@@.@..@@@@@@@@.@@@@@@@.@...@.@@@@@@@.@.....@.@@@.@.@.@@@
@.@..@@..@@@.@@..@@..@.@.@...@.@@@@@..@..@.@@..@@@.@@@@.@.@...@@@@..@..@@@@@@@@@@.@..@@.@@@@@@.@.@.@@@@@.@....@@@.@@@@..@....@.@@@.@@.@
.@.@@.@.@@@.@.@.@.@@@@.@.@@@@@.@@.@@.@....@@.@@.@@..@@@@.@.@.@@@@@.@@@@@@@@..@@@....@@@@@..@@@@@@@.@.@.@@..@.@@@..@@@@@@@@@...@@@@@@.@@
@.@@.@@@@@@.@@@.@@..@.@@.@@.@@..@@@@.@@.@@@@@.@.@@@.@...@..@.@@.@@@@@..@.@...@@@@.@.@@.@@@@@@@@@@..@.@@@@.@.@@.@@@@.@@@@@.@@@@@@@.@@@@@
.@.@..@@....@@@@@.@@@....@.@..@.@@.@@.@..@.@.@...@.@@@@.@..@.@@.@@@@@@@@@..@@@@@@@@@@@@.@..@@.@@.@@..@.@@.@@.@@@@@@@.@@@@..@@.@.@@.@@@@
.@@..@@@@@@@.@@.@.@@@...@.@@.@.@@@@@@@.@@....@@@@..@.@@..@@@@..@@@@@...@@.@@.@@@@.@@@..@@.....@.@@@@@..@@.@@@.@@@@@.@@.@..@...@..@.@@.@
.@@.@.@.@@@@@..@.@@.@@.@@...@@@..@@@@@.@.@@@@@@@@@.@@@@.@@@..@@@@@@@@@.@.@..@.@.@@@@.@@@.@@@.@@.....@..@@..@.@..@.@@@@.@@.@@.@@@@.@.@@.
.@@@.@@@.@.@..@@.@.@.@.@@....@.@.@..@..@@@@@...@@@@@@@@@@.@.@@@@@@.@.@@..@@@...@@@.@@..@@@@@.@..@..@@.@.@.@@@..@.@@@@@@@.@@@.@@...@@@@@
.@..@@@.@.@@@@@@@.@@.....@.@@@.@@.@@@@@@@@..@.@@@@.@@...@@@...@@@@.@@@@@@@@@......@..@@.@@@@@.....@@@...@@.@.@@@@.@..@@.@@@@@.@@@@@@@@@
@@.@.@..@@@@@@@.@@@@@@@.@.@.@.@@..@@@......@@.@.@@@@@@..@.@@@..@@@.@@@.@.@@@.@@@@@@@@@@.@.@@@@@.@..@@..@@...@@@...@..@@..@@@.@@@.@@.@@.
@@@@@.@@.@.@.@@..@@@@.@@@@@@..@@@@@.@..@@.@..@@@@@.@.@..@@.@@@@.@@@..@@@..@@@@@@@@@@@@@@@.@.@@..@.@@@@@@@@.@@...@@.@@..@@..@@@.@....@.@
@..@@@@@@.@@..@.....@@@..@@@..@..@..@@@@@@.@@@@.@.@@@@@@@@@@.@@..@@.@@@@.@@@@.@..@.@.@@@.@.@.....@@@@..@@@@.@@@@..@@@.@.@@@@.@@@@@.@@.@
..@.@@.@@....@.@@....@@..@@@.@@.@@.@@@..@.@@.@@@..@@@@@@.@@.@@.@@@.....@..@@@@.@.@@@@@@.@@.@@@.@@....@@.@@@@..@.@@@.@@@@...@@.@@@@@@.@@
@.@@.@@...@@..@@@@...@..@@@@@@@@@@@.@@@...@@@.@@.@.@.@...@@..@@@@@.@@@@@@@@@@@@@@.@...@@.@..@@@.@.@@.@.@@@@@@..@@..@@@.@@@.@@@....@@@@.
@.@@@@@@@@@@.@@....@@@@@.@...@@.@@@@....@.@.@@@@.@@@..@......@..@@..@..@@@@@.@.@@@@@@.@@@@@@...@@..@@@@@.@...@@..@.@@@@@.@@@@.@@..@@@@.
@.@@@@@@@.@@@@@@..@..@@@@..@.@@@..@.@@@.@.@.@.@@.@.@...@@@.@@@@@..@.@@@@@@@@.@@@..@@@@@..@@....@@@.@.@....@.@@...@.@@@..@.@@.@.@@.@..@@
@@@@@@@@.@@@@@...@@@@.@@@.@@...@.@@@@@@@@...@@@@..@@.@@@.@@@.@@@.@@@@..@@@@@@@@.@@.@.@.@@@@@@..@.@.@.@.@@@.@@.@@@@@@@@@@@@.@.@@@@@@..@@
..@..@@@@@@..@.@@@@.@@@@@....@@@.@.@@..@.@@.@.@.@@@@@@@.@@.@@@..@....@.@@@..@@.@.@@@.@@@@@@.@.@@@@@@@@@@.@..@@@@..@@.@@@@.@.@@@@.@@@@.@
@.@@.@@@@@.@@@@.@.@@@.@.@@@@@....@...@@@@@.@@.@@@@.@.@@@...@.@...@@@@@@.@@.@@@@@@.@@....@@..@@@@@@..@@@@@.@...@@@..@@..@@@@...@.@@@@@.@
.@@@@.@.@@@@@@@@@@.@@@.@@@..@.@@@@@@@@@@@.@@@@@.@..@@@.@.@@.@@..@@@@@@@@@@@.@.@..@@@.@.@.@..@@@.@@...@@@@@..@.@.@.@@@@@@.@@@@@@@.@@@@@.
@.@@@@.@@@@@@@.@@@.@@.@..@@.@.@@@.@.@....@.@@@@@@....@..@@@@.@@.@.@..@@@@@@.@.@@@@..@@@.@.@@@@.@@@.@.@@@.@@.@@...@@.@@.@...@.@....@@..@
..@.@.@..@@.@@@.@@@@@@@@.@.@.@@@@@@@.@.@@.@@@@@@@...@@@.@.@@@..@@@@..@@@@..@.@.@.@@.@.@@@@@..@.@@.@@@@.@@.@@@.@@..@@@@.@.@@@@@..@..@@@.
@@@@@.@@@@.@@@@@@@@@@@....@@.@@@@@@@@.@..@.@@.@@@...@@.@@@.@@...@@@@@@@@..@.@@.@.@.@@@@.@@...@...@.@@@@..@@.@.@.@@@@@@.@@.@@...@..@....
@.@@@@@.@.@..@@.@@.@.@.@@@@@.@@@@..@@.@@....@@..@.@@@..@.@@@.@.@@@..@.@.@@@@@@..@@.@@.@@@.@@@@@.@@@.@@@@@@@@.@@.@@@@@.@@@@@@@@...@...@.
@.@@@@@@@@.@@@@..@@@@@@.@@@@@@@@@@@@@.@@.@@@@@@@@@@.@@@@@.@.@@.@@@.@@@.@.@.@@@.@.@@..@@.@@@.@@.@.@...@@@.@@@@@@@@....@@@@@..@.@@@@@@.@@
@@@@@@....@..@@...@@@@..@.@@@....@@..@@@@.@@.@@..@@@@@@@..@..@.@..@@..@@@@@@@.@.@@.@@@@.@@..@@@@@.@@@@.@@@..@@@.@...@@@@@..@..@.@@@@@@.
@@..@.@.@@@@@..@@.@@@.@@.@@@@@.@@@@@@.@@.@....@.@@@.@.@....@.@@..@...@@@.@@@@...@@@@....@@.@@@..@...@..@..@@@@@..@@....@.@@@@@.@.@..@@@
.@@@@@@.@@@.@.@@@@......@@@..@.@.@@@.@@@.@.@@.@@@@.@@@.@@.@@@@@@@@@@@.@@.@@@@@@@.@@@.@..@@@@@...@@@@@@@.@..@.@@@@.@@.@@..@@..@@@@@@@@.@
@@@@..@@@@@@@..@@@@@@.@.@@@@@.@.@@...@@@...@@@@.@.@@@.@@@@..@..@.@@.@..@@...@.@.@.@.@@@@.@@@@.@@@.@.@.@@@@.@.@@@@@..@@.@.@@@.@@@@..@@@.
.@@.@@@.@..@@...@@@@@@@@.@@@@.@@..@..@@@@@.@@@@.@@..@.@...@@.@.@@@@.@@...@.@.@...@.@@@@@...@@@@.@@@..@..@@@@@.@@@@@@@.@@@@@@@.@.@.@@.@@
@@.@@......@@@@@@@@.@..@@@@@..@@@.@@@.@@..@@.@@@....@@.@@@@@@@@@@....@...@@@@@@@@@@@@@@@@@..@@@@@@...@@@.@@.@@@@@..@@..@@..@.@.@@@@@.@.
@@..@@@@@....@.@@.@@@@@@.@@.@@@@..@@..@@@@..@@@@.@@.@@@@@.@@@@@.@@@@@@@.@.@@@..@@@.@@@@.@@@@@@@@@@@@@@@....@@@@@@@..@.@@.@@@@.@.@.@@@@.
@@.@@@..@.@@@@.@@....@@@@@.@@@@.@@@@@@.@..@@@@@@@@@@@@.@@.@.@@....@.@..@..@@@@@@@.@.@@@.@..@.@.@.@@@@.@@.@@@@@.@@@@@@@.@@@@@..@...@@@..
.@@.@@@.@.@@@@.@...@@..@.@.@..@@.@@.@...@@.@.@@..@.@@@@@.@@@.@.@...@.@.@@.@@@@@.@@@@.@@@@@.@..@@@@@@@.@.@..@@....@..@@...@@@@@@@...@.@@
@..@@@.@@@@@@@..@.@.@@.@@@.@@@.@@..@.@.@@@@..@.@@.@@.@@.@@.@@.@.@....@@@.@@@@@@.@..@@.@.@@@.@@@@@@@@@@@..@@@@.@.@@@.@@@@@.@.@.@@@@@..@@
.@@.@@@@.@.@@.@@..@.@.@..@@@..@.@@@.@.@...@@.@@@@@@.@@@.@@.@@.@@@@@.@@.@@@.@@@@.@..@..@.@@@@.@@@@@@@.@@@@....@@@@@.@.@@@..@.@@@.@@..@@@
@@@@@@.@.@.@@@@@@..@@@@@@.@@@@@@.@@@@..@.@@...@....@..@.@@@@@...@@..@..@.@@..@@@@.@@.....@@@@@@@.@@...@@.@@.@..@@..@@@.@.@@.@.@@..@.@@@
.@.@...@@@@@.........@@@.@@@@..@...@@@@..@@.@.@.@.@@@.@.@@@@.@@@@...@@@..@@@@@@@@@@@@@.@..@..@@@@..@@..@@.@@@@@@@@.@@@@@.@@@..@.@@..@.@
@@.@....@.@@@...@@.@@@@@@@.@@.@...@@@@@.@@@@..@@..@@@@@..@..@@@@@.@..@.@@....@@@.@@@@.@.@@..@@@@@@@@@@@..@..@..@@..@@..@@@@.@@@@.@@.@.@
.@@@@...@..@@@.@@.@.@....@@.@@@@@@@@...@.@@@...@.@.@@@.@@@.@@@@.@..@.@..@..@..@@@@@@..@@@@.@.@.@.@.@.@@@@@@@@@@.@..@.@@@.@@@@@.....@@@@
@@@..@..@.@@@@.@.@@.@@@...@@@@@@@@@.@@@@@@@.@.@.@.@@@@.@@@@.@.@@..@@@..@@@@.@@@.@@..@.@@@...@.@....@@@@@.@.@..@..@@@@..@@@@.@@.@@@@@@@.
.@@@@..@@@@@@@@@.@@@@@@@.@@@@...@@@@@@....@@@@@@@@@@@@..@@@@@@.@.@@.....@@@@.@@@@@..@@@@@@@@@@.@@@@@.@@@@@@@@@@@@@@.@.@@.@@.@..@@@.@@..
@@@..@.@.@@@@....@.@.@.@@@@@@.@@.@@..@@.....@@.@@@@@.@@..@@@.@@.@.@@@@@...@@.@@@..@@..@@.@@@...@@.....@.@@..@@@.@.@@@..@.@@@.@@@..@@@@@
@@@.@.@..@..@@@@.@.@@@.@@@@@.@.@@@@@@@@.@..@@.@...@@@....@@@.@@@@..@@@@.@@@@.@..@@...@....@@..@@@@.@@@@@@@@@@@@@@@@.@..@.@@..@@.@@.@..@
...@....@.@@@@@@@@@..@@@@@.@@@..@@@@.@...@@@.@@@.@@.@..@...@@@..@.@@.@@@@.@@.@@@.@.@@..@@@..@@.@@..@@@@.@@@@@@@@....@...@.@.@....@@@..@
@.@@@.@@@@.@@.@.@@..@@..@.@.@@@@.@..@@@.@@@.@@@......@.@.@@....@@.@.@@@@@@.@@@.@@@.@@@.@@.@@@@...@@.@@.@@.@.@@@@@@@@@@.....@.@.@..@@@@@
@.@....@@.@@@@@.@@.@@..@.@@.@@@@.@@.@.@@.@.@..@@@@@.@@@.@..@@.@.@.@@...@@.@@.@@@@.@.@@.@@@@@@@@@@@@@@@.@@@@@@@.@.@@.@@.@@.@@..@@@@@@@@@
@@.......@@.@@...@@@@@@.@@@@@@@.@.@@@.@..@@.@.@@@.@@.@@@@@.@..@@...@.@@@..@@.@@....@.@.@@@@@@@....@@@..@@@@@@@@..@.@@@@@..@@@@@.@...@@@
@...@.@..@@@@@.@......@..@.@..@..@@@..@@@@@.@@@@@..@@@@@@@..@@.@@@.@.@..@@@..@@.@.....@.@@@.@@@@.@@..@@@@@@@@.@...@@@@@@@@@@.@.@@@@..@.
@.@@.@@...@@.@@..@.@@@@.@.@@@@..@@@.@.@@.@@.@@.@@.@@.@@@@@@@@@.@@.@@.@@@..@@.@@@@.@@.@@.@@.@.@@@@@@@@@@..@@@..@@..@@@.@..@@@..@@@.@.@@@
@@.@..@@.@@@@.@@@@@@@@..@@.@@.@.@@@.@@@..@@@@.@@@.@@.@@@@@@@@@@@@@.@.@@@@.@@.@..........@.@..@@@@@@@...@..@...@..@..@@@.@@.@@.@@.@@@.@.
..@@@@@@.@...@@@..@@.@@@.@@@@@@@@......@@..@.@.@@@@@@@@..@.@@.@..@@@@@.@@.@@@.@.@.@@@@.@@@@@.@.@.@@.@@@@@.@@@@@..@..@@.@.@.@@..@.@..@.@
...@@.@@@@@@@.@@@.@@@@@@@@@@@@@.@...@@.@.@.@@@@@@@..@@@@@@@.@....@@.@@..@@..@@@.@@@..@@@.@@.@@@.@@@@@@@.@@.@..@..@.@@..@@@@@@@@..@@.@@@
.@@@@.@@@@@.@@@@...@.@.@@@@@..@.@@.@@@@.@@@@@.@@.@....@@@.@...@.@@.@.@@@@.@..@@.@@.@@@.@@@@@.@.@@@...@@..@@@@..@@@...@.@@@@@@@@@..@@.@@
..@@@.@..@@.@@@@@@@@.@.@@.@@@@@.@.@@@.@@@..@@.@@@@@@@@..@.@@.@@.@..@@@@@.@@.@@@@@@@@..@@@@.@@@.@@@.@.@..@.@@..@@@@@@@.@@@@@..@@.@@@.@@@
@@@..@..@...@@@@@@@.@@..@.@.@@@@@@@@@@.@@@@@.@.@@@@.@@@@@@@@@@@@@@@@@@@@@@@@.@@@.@@..@@@.@@.@@@.@@.@@.@..@@...@@@.@@@@@@@....@@..@@...@
..@.@..@@.@...@.@.@@@@@@.@....@.@.@@.@@@@@@@@@.@@@@@@@@@@.@@@@..@@.@@...@.@@@@@.@@..@@.@@.@@..@.@.@.@.@@@.@@@@@..@@..@.@.@@.@@@@@@@..@@
.@.@@@@..@@@.@@@.....@.@...@@.@@.@@@@.@@.@@@...@....@@@@@..@.@@@@...@@@@@.@@@..@@.@@@@@@.@@.@@@@@@.@@@...@@@@@..@.@@@@..@@@@.@@@.@@@@.@
.@@@@@@@@@.@@.@.@@.@@.@.@@.@@@@.@@.@@@.@@@@@@@@@@.@@@.@@.@@@.@@@....@@@@@@@@.@..@@.@@@@..@@....@.@.@@@@.@.@...@@.@...@@@@.@@...@@.@@@.@
@@@@@..@.@@@@@@@@.@@@@@@.@@...@.@...@@.@@@@@.@@.@@@.@@@@@@@.@.@@@@@...@@@@@..@@@@@@@@@@@@@@....@@.@@..@@@@@@@.@@@@@.@@.@@.@.@...@...@.@
@@.@...@....@@@@@@.@.@@@..@@@.@@@@@@@.@@.@@@.@@.@.@@@.@@@.@@@..@@.@@@@@.@.@@@@@.@..@@@@@@@@@.@@@@..@.@@@.@@@.@.@.@@@.@@@.@@@@.@.@..@@..
.@..@@.@.@@.@@@@.@.@@..@@@..@@@@@@@@@.@..@@.@.@@.@@@@.@..@@@@@..@.@.@..@..@@.@.@@...@.@@@.@.@@@@@@@@@@@@@@@@.@@@@.@@@.@.@@.@@@.@@@@@@@@
..@@...@.....@@@@...@@.@..@@@.@@@..@@@@.@@@.@.@@@@.@@..@@@@.@@@@@....@@.@@@.@@.@@@@@@@@@@@.@...@@..@@......@@@@.@@.@.@@...@@@@@@.@@..@.
@.@@@@@@...@@..@@.@@.@.@@@@@@.@..@@@@@@.@...@.@@@@.@@@@@@.@@@@..@@@@..@@@@@@.@@@@@..@.@@.@@@@@@@@.@@@.@.@..@@@@@.@@@@@.....@.@.@.@.@@@@
@.@@...@@@@.@@@.@@@@@.@@.@.@@@@..@@..@@@.@@@@@.@..@@@@@@..@@@@..@..@@..@@..@@@@@@@.@@@@@.@.@@@@@@..@@.@@@..@@@..@@..@..@@@@@.@@.@.@.@.@
@@@@@@@.@@@@@@@@.@@@@.@.@@@.@...@@@.@@..@@@@@@@@@.@@@.@..@@.@@@@.@.....@.@@...@.@@.@....@@@.@@..@@@@.@.@@@..@@.@@..@@@@@@@..@.@@@@@.@.@
@.@@..@@@@.@@...@@..@@@@@..@@@..@@....@@@..@.@.@@@.@.@@@.@@.@.@@@@.@.@....@@.@@@@@@..@@.@@@@@@@.@@.@@@@@@..@@...@@..@@..@@.@..@.@@@@..@
.@@@@@...@@@@@@..@@@....@@...@@@@@@.@.@.@.@..@@@@@.@@@@@@@@@@.@@@...@.@.@.@..@....@...@@@@...@.@@@@@.....@@@@@@@@@..@@@@...@.....@@@.@@
@..@.@.@@.@..@@@..@@@.@@.@@....@@@@.@@@@@..@.@..@@@@@@@@@@@.@@.@@@@@@..@@@@..@@@@@@.@..@@@@.@......@@..@@@@@@..@@@.@@@..@.@@..@.@@.@@.@
@@@.@@@@@@@@@@@..@@@@@@@@@.@...@.@....@.@.@@@@.@.@@..@.@@@@@.@@@@.@@@@@.@@@@..@.@..@.@@@..@@...@@..@@@@@@.@@@.@@.@.@@@.@@.@@@@.@@.@@@@.
.@@@.@@@.@@@.@@@@.@@@@.@...@@@@@.@....@.@@..@@@@..@.@@@@@@@@@...@@@@..@@@@@@@@@..@@@.@.@.@@@..@@.@.@@@.@..@@.@.@@@@@.@@.@.@@@@.@@@.@@.@
@@@@@@.@.@@@@@@@@..@..@@@.@@@..@@.@@@.@@@.@.@@.@@@..@@@@.@@@@.@@@@.@@@.@@@@@@..@@..@@.@@@@..@@..@.@..@@.@@@.@@.@.@.@@@@.@@@@.@@@@.@@@@@
@@@.@@@@@@@@.@@@...@@@@@@.@.@@@@@.@@.@@@..@@@@@..@..@@@@.@.@....@@.@@@...@@@.@@@..@@@@..@@@@.@.@@@..@@.@.@@@@@@.@.@@@..@.@@..@.@@@@@@@@
@@@...@@.@@@@@@.@.@@.@@...@@@@..@.@...@@@.@@.@@@.@@.@..@@...@@..@.@@@@@.@@@@.@.@@@@@@@@@.@.@.@.@..@@...@.@@@@@@@@@@@.@..@@@..@@@@@@@.@.
.@@@@@@.@@.@@@.@...@.@@.@@...@.@@@.@..@@@@.@@@@@@@@...@.@@@@.@@@.@@.@..@.@.@@.@@@@@....@.@.@@@@@@.@@@..@@@@.@.@.@.@@@@.@@@.@@.@@..@@@@.
@@@@@@@@@@@@@@@@@..@@..@.@@@.@@@.@@@@@...@@@@.@..@@@@.@@@@@@@@.@.@@.@.@@@@.@.@.@@@@...@@.@.@@@@.@@@@@..@@@@@@@..@@@.@@@@.@@@@@.@@@@@...
@@@@@@@@..@...@.@@@@@@@.@.@@@@.@..@.@@@..@@.@.@@@@..@..@@..@@.@.@@..@@@@..@@@.@@@..@@@..@@...@@@...@.@..@@@@@@...@.@@..@@.@@.@..@@@@@@@
@.@@@@@@......@@@@.@..@@@..@@.@@.@@..@@@@@@@.@.@@@@@@.@.@@@@..@@@.@@.....@..@@.@@.@.@.@.@@.@@.@.@@.@@@@@@.@@@..@.@@@.@@.@@.@.@@@...@..@
@@@@@.@@@@.@.@@..@@@@.@@..@@@.@@@.@@.@.@.@..@.@.@@@@@.@.@@@@.@.@@@@@@@@...@@@@@@@@..@@....@@.@@@.@@@@@@@@@@@@@@@@@..@@.@..@.@@@@@.@.@.@
@@@.@@.@@@@....@@@@.@@@@.@@@@.@@@.@..@@...@@.@@@@.@@@@...@@@.@@..@@@@@.@@@@@@.@@@.@@..@@@@.@@@@@@@@@@..@@@.@.@@@...@@@@@..@.@@@@.@.@...
@@@.@@@.@@.....@@.@@@@@@@.@@.@@@.@.@@.@@...@.@@.@@..@.@...@@.@.@@@...@@@.@..@@@@@.@@@@@.@@@@.@@..@@@...@.@.@@...@@@.@@@@.@@@.@.@.@...@@
@@..@...@.@@@.@@@@@@@@@@....@.@@@@..@.@@@@....@...@@@.@@.@@....@@..@......@@@..@.@@..@@.@@..@@@.@@.@....@..@@@...@@.....@@@@@@@@@.@.@@@
@.@.@.@@@.@.@@@.@@@@@@@@@@@..@@@@@@@@.@@@@@@.@@@..@@@@.@@@@@@@@@.@@@@@@@@.@@.@.@..@.@@.@@@.@.@..@@@.@.@.@.@.@@.@@..@@....@.@..@..@@@@.@
@@@@@@.@.@@@@@@..@@..@..@@@@@@@@@@@.@...@@.@@@@@@@@.@...@....@@....@@@@.@@....@@.@@..@@.@..@.@@@.@.@@@@@@@..@@@.@.@@@@@@......@.@@@.@@@
.@.@@.@@@@..@.@.@.@@@@.@.@@@@@@@.@@@.@@@..@@@.@@.@@.@@@@..@.@@@@@@@@@@.@@@@@@@@@..@@@@.@@@@@@@.@.@@.@@@.@@@@@@@@@.@@@@@@@@..@@@@@.@@.@.
..@@.@.@@@.@.@@@@@@@@.@@@..@@@@..@@.@@.@...@@@..@.@.@.@@..@@@@.@@@@..@@@@@..@..@@@@@@@@.@.@@@..@@.@.@@@.@@@@@...@@@@@@.@....@@@.@@@@@@@
@@.@@.@@@@..@@@@@@..@@..@.@@@@@@.@@@@@.@..@.....@.@.@@@.@@@@@@.@@@..@..@@@....@.@.@.@.@@..@@.@.@..@.@@@@@@@@@.@.@@@@@@.@@@@...@.@....@.
@@@..@..@@.........@@@@.....@@.@@@@@@@.@..@.....@..@...@..@@@....@..@@..@.@.@..@@@@@@.@@@@@..@@@@@...@.@@@@@@@.@@@@@..@@..@@@@.@@...@.@
@@.@@.@@@@@@@@..@@@@.@@..@.@.@@@.@@..@@.@@@@@@@.@.@@@.@@@@@.@..@.@@@@@@.@@@@.@@..@@@@@@@.@@.@@@@@..@@@@@.@@@.@@..@..@.@@@@@.@@.@.@.@@@.
.@@@@.@@@@@.@@@..@@.@@@@@@.@@@@@@.@.@@@@...@@@.@..@..@.@@@@.@@@.@.@.@.@@.@...@@@.@.@@@.@@@@.@@@@.@@@@@@@..@.@@@.@@@.@@.@@@@@@.@@@.@@@..
.@.@@@@@.@@@.@@..@@....@@.@@.@.@@@@@...@.@.@.@@@@.@.@.@.@.@.@@@@@..@@@@.......@.@@.@@..@.@@@@@@@.@.@@@@.@@...@.@@@@@.@@@..@..@....@@@@@
.@.@.@@..@..@..@@@.@@@@@@@@.@@.@@@@@@.@@.@..@.@@.@.@.@.@@@@@.@@@@@@@@@.@...@@.@...@@.@@.@..@@.@@@@@.@.@..@...@.@@...@@@@.@@@.@@@@.@@@@@
@..@@.@@.@.@@.@..@.@.@..@@....@@.@..@..@@@.@.@@@.@.@@@@.@@@@.@@..@@.@.@.@@..@@@@@@@@@@@@@@.@..@@@.@@....@@@@@@@@.@.@@.@@@@@@.@..@@@@@..
..@@@@@@@@@@@@@.@@@.@.@@.@@.@.@@@@@@.@@@.@@@@..@@@@......@...@@@@@.@@@.@..@..@.@.@..@..@..@@.@@@..@@.@@.@@@.@..@@..@@@@.@@@..@@@@..@@@@
@@@@@@@@.@@@.@@@@@..@.@@@@@.@@@@@@@.@..@@@@@@@...@@@@@.@@@@@..@....@..@......@.@@..@@.@@@@..@@.@.@.@..@..@@@@..@@.@..@@..@@@.@.@@@@..@.
@@@.@@@...@@@@@@.@@....@....@..@@@.@@.@.@.@@@@@@.@.@.@@@@...@@@@....@.@.@@.@@@@@@@@@.@@@@@@@@.@.@@.@@@@@@.@@@.@@.@@@@@..@@@.@@@.@...@..
....@@@....@@.@..@@@.@@@@..@..@@@.@@@.@.@.@@.@...@@@@@..@..@...@@.@.@@....@@@.@.@@.@..@..@@@@...@@@@@@@@@@@.@@..@@@@@.@.@.@.@@....@@@.@
@..@@@@@.@@..@@...@@@.@@.@..@@@@@@@@@@@@@.@.@@@@.@@@...@.@@..@@@.@.@@@@@....@@...@@.@.@.@@@.@@.@@..@.@.@..@.@@@.@@@@@.@...@.@@@.@@@@.@@
@@@@@@@@@..@@@@.@@.@@.@..@@@@@@@.@...@.@@@@@@@@.@@@@@@@@.@@..@@.@.@@@.@@@@.@@.@@@@@@..@@.@@@@@@@.@.@..@@@@@@.@..@@@@.@@@..@@...@@@@@@..
@@.@@.@@@@..@@.@.@.@@.@.@@.@.@@..@@@..@@.@..@@@@@...@@@@@@..@@@@@.@@.@@.@.@@@@..@.@.@.@@..@@..@.@@.@.@...@.@..@..@.@.@@@@..@.@.@@.@@...
.@@.@.@.@@.@..@@@@.@..@.@.@..@@@@@.@@@...@@.@@@@.@@..@@.@.@@@@...@@.@@.@..@@...@@.@@@.@..@@.@...@.@@.@@.@.@.@@@@.@.@@@@@@@@.@@.@@@@@@@@
@.@@@@@....@@@@.@@@@@@@@@@@@...@@@@@@@@@..@@@@..@@@@@@.@@@@.@.....@@..@@@.@@@@@@.@.@@...@@@@@@@..@@@@@@@.@@@@@@@@..@@...@@..@...@...@.@
@@@.@@.@@.......@.@@@@@@@.@.@@.@@@@.@..@@..@@@@@@@@@@@..@@@@@...@@..@@@.@@..@@@@.@.@@..@@@@@@@.@@@@@.@@@@@@.@@.@@.@@@@@@@@@@@@@@.@.@.@@
@.@@@@.@@@@.@.@@@..@@.@.@@.@@@...@@@....@@@@@.@@@..@@.@..@......@.@@@...@@@@.@@...@@@@.@..@@@@@.@@@@@@.@@..@@.@.@@@@@.@@@@@@@.@@@@..@@@
...@.@.@.@@@@.@@@@.@@@@..@@..@...@@..@@@@@@@..@@.@.@@.@..@@.@@@.@@@@.@@@.@@@@@.@@.@@@@@.@@@@.@.@@@.@@.@.@..@@@@@@@..@@@@.@@@@@@.@@@@@@@
@.@..@.@.@.@.@..@@.@.@@@@@@@@@.@@@@@@.@.@@...@.@@..@@....@@@.@@@...@..@@@@@@..@@...@@@@@.@@@@@@@@@@@@@.@@.@@@@..@.@.@..@@.@@@@@@@@@@.@@
@.@@@@..@@@@..@.@@.@@.@@@@.@....@.@@@.@@@@@@@@@..@@@.@.@@.@@..@.@@@@.@@...@@..@@@@.@.@@.@...@.....@@@@@@@@@@..@@@.@..@@@@@@@..@@.@@.@@@

10
2025/Day4/test Normal file
View File

@@ -0,0 +1,10 @@
..@@.@@@@.
@@@.@.@.@@
@@@@@.@.@@
@.@@@@..@.
@@.@@@@.@@
.@@@@@@@.@
.@.@.@.@@@
@.@@@.@@@@
.@@@@@@@@.
@.@.@@@.@.

94
2025/Day5/Day5.lua Normal file
View File

@@ -0,0 +1,94 @@
-- Using Autorun now
print("Starting Day 5...")
local input_file = "Day5/full"
local DEBUG = false
local Freshness = {
Range = {},
}
function debug(msg)
if DEBUG then
print(msg)
end
end
function Freshness.add(R)
local S, E = string.match(R, "(%d+)-(%d+)")
local Set = { tonumber(S), tonumber(E) }
table.insert(Freshness.Range, Set)
end
function Freshness.show()
for k, v in pairs(Freshness.Range) do
print(string.format("%d-%d", v[1], v[2]))
end
end
function Freshness.check(value)
cv = tonumber(value)
for k, v in pairs(Freshness.Range) do
if cv >= v[1] and cv <= v[2] then
return true
end
end
return false
end
function Freshness.CalculateIDs()
-- Copy and Sort
table.sort(Freshness.Range, function(a, b)
return a[1] < b[1]
end)
local IDTable = {}
local count = 0
for kadd, vadd in pairs(Freshness.Range) do
local merged = false
debug("Checking " .. vadd[1] .. "-" .. vadd[2])
for kcheck, vcheck in pairs(IDTable) do
-- Check Lower
debug(" Compare " .. vcheck[1] .. "-" .. vcheck[2])
if vadd[1] >= vcheck[1] and vadd[1] <= vcheck[2] then
if vadd[2] > vcheck[2] then
debug(" Lower number inside range and higher number higher")
IDTable[kcheck][2] = vadd[2]
end
merged = true
end
-- Check higher
if vadd[2] >= vcheck[1] and vadd[2] <= vcheck[2] then
if vadd[1] < vcheck[1] then
debug(" Higher number inside range and lower number lower")
IDTable[kcheck][1] = vadd[1]
end
merged = true
end
end
if not merged then
table.insert(IDTable, vadd)
end
end
local countIDs = 0
for k, v in pairs(IDTable) do
countIDs = countIDs + (v[2] - v[1]) + 1
print(string.format("Range %d-%d = %d Total %d", v[1], v[2], (v[2] - v[1] + 1), countIDs))
end
return countIDs
end
local InputMode = true
local FreshCounter = 0
for line in io.lines(input_file) do
if line == "" then
InputMode = false
elseif InputMode then
Freshness.add(line)
else
if Freshness.check(line) then
FreshCounter = FreshCounter + 1
end
end
end
print("Found Fresh Ingredients " .. FreshCounter)
print(string.format("Found IDs %18.0f", Freshness.CalculateIDs()))

1174
2025/Day5/full Normal file

File diff suppressed because it is too large Load Diff

11
2025/Day5/test Normal file
View File

@@ -0,0 +1,11 @@
3-5
10-14
16-20
12-18
1
5
8
11
17
32

33
2025/README.md Normal file
View File

@@ -0,0 +1,33 @@
# Advent of Code 2025
## Introduction
This is mostly so I can keep notes on my progress, in single markdown format so I can easily add it to my Silverbullet journal afterwards.
## Lessons from first day
1. Read! Oh that brain of mine, skipping half the things and missing things like count clicks not end point dial
2. Setup a proper test, make a smaller input test that you know the answer to to check the code
## Lessons second day
1. More git commits!
2. Clear history so you don't accidentally cp day1 to day2 during testing. (Undo FTW)
3. Put the central check (Serial Valid/Invalid) in a function so it's easy to add self checks in the beginning
## Lessons third day
1. Can't win em all
2. Code is much shorter because I'm getting better with Lua, yay
## Lessons fourth day
1. Need about an hour to do both, but also speeding up
## Lessons fifth day
1. Lua has a maximum table size, so no brute forcing :)
2. When doing any type of comparing, a good pre-sort helps

22
2025/autorun.lua Normal file
View File

@@ -0,0 +1,22 @@
-- Use this to get the buffer ID where you want the output
-- echo nvim_get_current_buf()
vim.api.nvim_create_autocmd("BufWritePost", {
group = vim.api.nvim_create_augroup("AutoRunCode", { clear = true }),
pattern = "*.lua",
callback = function()
local bufnr = 21
vim.fn.jobstart({ "lua", "Day5/Day5.lua" }, {
stdout_buffered = true,
on_stdout = function(_, data)
if data then
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, data)
end
end,
on_stderr = function(_, data)
if data then
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, data)
end
end,
})
end,
})