diff options
| author | Andreas Grois <andi@grois.info> | 2025-12-17 07:30:19 +0100 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2025-12-17 07:30:19 +0100 |
| commit | dcebd44260fa67b04d217e778265982393ccc032 (patch) | |
| tree | b8eaf3de339d7a389632123c4765c53cce507a44 /day4/part1.TXT | |
| parent | 7c225da26c5be1c255db34b52548b3af49097b07 (diff) | |
Diffstat (limited to 'day4/part1.TXT')
| -rw-r--r-- | day4/part1.TXT | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/day4/part1.TXT b/day4/part1.TXT new file mode 100644 index 0000000..31cdfdf --- /dev/null +++ b/day4/part1.TXT @@ -0,0 +1,44 @@ +\START92\
+\COMMENT=Part1 Day4 s: parsed input, w: input width
+\NAME=part1
+\FILE=day4.part1.92f
+(s,w)
+Func
+Local h,i,j,curr,prevs,pc,result
+
+dim(s)\->\h
+If h<1 Then
+ Return 0
+ElseIf h=1 Then
+ Return cntbits(s[1])
+EndIf
+
+0\->\result
+For i,1,w
+ newList(3)\->\prevs
+ false\->\pc
+ For j,1,h
+ getbits(s[j],i-1,3)\->\curr
+ cnt3bits(curr)\->\prevs[mod(j,3)+1]
+ \(C)\'and' is not short circuiting
+ If pc Then
+ If sum(prevs)<5 Then
+ result+1\->\result
+ EndIf
+ EndIf
+ curr=2 or curr=3 or curr=6 or curr=7\->\pc
+ EndFor
+ \(C)\ last line
+ If pc Then
+ 0\->\prevs[mod(h+1,3)+1]
+ If sum(prevs)<5 Then
+ result+1\->\result
+ EndIf
+ EndIf
+EndFor
+
+result
+
+EndFunc
+
+\STOP92\
|
