Worthless fucking language

Fuck
This commit is contained in:
Thomas Muller 2022-12-04 01:56:55 -05:00
parent 8030f8a4e4
commit e1fb818195
Signed by: thomas
GPG key ID: AF006EB730564952
2 changed files with 1065 additions and 0 deletions

1000
day_4/input.txt Normal file

File diff suppressed because it is too large Load diff

65
day_4/main.txt Normal file
View file

@ -0,0 +1,65 @@
@name Day 4
@inputs
@outputs
@persist Lines:array Overlaps:number Overlaps2:number I:number Done:number
@trigger
runOnTick(100)
runOnFile(1)
if(first()){
print("load")
fileLoad("input.txt")
Overlaps = 0
I = 1
}
if(fileLoaded() && Lines:count() == 0) {
Data = fileRead()
Lines = Data:explode("\n")
#print(Data)
}
In = "2-4,6-8\n2-3,4-5\n5-7,7-9\n2-8,3-7\n6-6,4-6\n2-6,4-8"
#Lines = In:explode("\n")
#print(In)
if(Lines:count() != 0 && Done == 0) {
while(perf()) {
#print(Lines[I, string])
V = Lines[I, string]
Pair = V:explode(",")
First = Pair[1, string]:explode("-")
Second = Pair[2, string]:explode("-")
L1 = First[1,string]:toNumber()
R1 = First[2,string]:toNumber()
L2 = Second[1,string]:toNumber()
R2 = Second[2,string]:toNumber()
Ol = (L1 <= L2 && R1 >= R2) || (L2 <= L1 && R2 >= R1)
if(Ol) {
#print(Pair, "overlap")
Overlaps++
}
Ol2 = (L1 <= R2 && L2 <= R1)
if(Ol2) {
#print(Pair, "overlap")
Overlaps2++
}
#print(D1, D2)
I++
if(I > Lines:count() - 1) {
Done = 1
break
}
}
}
print(Overlaps, Overlaps2, I)