repositories
/
advent21.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
cleanup
[advent21.git]
/
08a.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdbool.h>
5
6
int
main
()
7
{
8
char
*
buf
=
NULL
;
9
size_t
len
=
0
;
10
int
r
=
0
;
11
12
while
(
getline
(&
buf
, &
len
,
stdin
) != -
1
) {
13
char
*
p
=
strtok
(
buf
,
" "
);
14
bool
inoutput
=
false
;
15
while
((
p
=
strtok
(
NULL
,
" "
)) !=
NULL
) {
16
if
(
strcmp
(
p
,
"|"
) ==
0
)
17
inoutput
=
true
;
18
else if
(
inoutput
) {
19
int
l
=
strlen
(
p
);
20
if
(
p
[
l
-
1
] ==
'
\n
'
)
21
p
[(
l
--)-
1
] =
'\0'
;
22
if
(
l
==
2
||
l
==
3
||
l
==
4
||
l
==
7
)
23
r
++;
24
}
25
}
26
}
27
printf
(
"%d
\n
"
,
r
);
28
}