summaryrefslogtreecommitdiff
path: root/day1/part1.TXT
blob: d4d93e32697e5af43596bc5c4f0fed5bf9eddb1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
\START92\
\COMMENT=Single file dated Tue Dec  2 23:20:40 20
\NAME=part1
\FILE=day1.part1.92f
(inp,position)
Func
Local pos1,pos2,curr,sig,direct,step,result
0\->\result
1\->\pos1
While pos1<dim(inp)
 inString(inp," ",pos1)\->\pos2
 If pos2<1 Then
  dim(inp)+1\->\pos2
 EndIf
 mid(inp,pos1,pos2-pos1)\->\curr
 pos2+1\->\pos1
 If dim(curr)=0 Then
  continue
 EndIf
 left(curr,1)\->\direct
 If direct="L" Then
  \(-)\1\->\sig
 ElseIf direct="R" Then
  1\->\sig
 Else
  Return {\(-)\1,position}
 EndIf
 expr(right(curr,dim(curr)-1))\->\step
 mod(position+sig*step,100)\->\position
 If position=0 Then
  result+1\->\result
 EndIf
EndWhile

Return {result,position}
EndFunc

\STOP92\