repositories
/
advent21.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
day four
[advent21.git]
/
02a.l
1
%option noyywrap
2
%option noinput
3
%option nounput
4
%{
5
#include <stdio.h>
6
int x = 0, z = 0;
7
%}
8
9
%%
10
forward\ [0-9] x += atoi(yytext+sizeof("forward"));
11
up\ [0-9] z -= atoi(yytext+sizeof("up"));
12
down\ [0-9] z += atoi(yytext+sizeof("down"));
13
\n ;
14
%%
15
16
int main (void)
17
{
18
yylex();
19
printf("%d\n", x*z);
20
return 0;
21
}