summaryrefslogtreecommitdiff
path: root/day5/part2.TXT
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2025-12-19 22:20:34 +0100
committerAndreas Grois <andi@grois.info>2025-12-19 22:20:34 +0100
commit375169efa68219af7e53ab24b10cfb8e5ee988ab (patch)
tree5a39f0487942ef50b45991a77d47ec09c15fe2be /day5/part2.TXT
parentdcebd44260fa67b04d217e778265982393ccc032 (diff)
Diffstat (limited to 'day5/part2.TXT')
-rw-r--r--day5/part2.TXT44
1 files changed, 44 insertions, 0 deletions
diff --git a/day5/part2.TXT b/day5/part2.TXT
new file mode 100644
index 0000000..790c74a
--- /dev/null
+++ b/day5/part2.TXT
@@ -0,0 +1,44 @@
+\START92\
+\COMMENT=Single file dated Fri Dec 19 22:13:14 20
+\NAME=part2
+\FILE=day5.part2.92f
+(rs)
+Func
+Local i,j,lowerb,upperb,dimb
+
+mat\to\list(rs[1])\->\lowerb
+mat\to\list(rs[2])\->\upperb
+dim(lowerb)\->\dimb
+
+For i,dimb,1,\(-)\1
+ For j,dimb,i+1,\(-)\1
+ If lowerb[i]\>=\lowerb[j] and upperb[i]\<=\upperb[j] Then
+ lowerb[dimb]\->\lowerb[i]
+ upperb[dimb]\->\upperb[i]
+ dimb-1\->\dimb
+ Exit
+ ElseIf lowerb[j]\>=\lowerb[i] and upperb[j]\<=\upperb[i] Then
+ lowerb[dimb]\->\lowerb[j]
+ upperb[dimb]\->\upperb[j]
+ dimb-1\->\dimb
+ EndIf
+ EndFor
+EndFor
+left(lowerb,dimb)\->\lowerb
+left(upperb,dimb)\->\upperb
+
+For i,1,dimb
+ For j,i+1,dimb
+ If upperb[i]\>=\lowerb[j] and upperb[i]\<=\upperb[j] Then
+ lowerb[j]-1\->\upperb[i]
+ ElseIf lowerb[i]\>=\lowerb[j] and lowerb[i]\<=\upperb[j] Then
+ upperb[j]+1\->\lowerb[i]
+ EndIf
+ EndFor
+EndFor
+
+sum(upperb-lowerb+1)
+
+EndFunc
+
+\STOP92\