Name | Language | Tokens Sum | Tokens Part 1 | Tokens Part 2 | Last change | |
---|---|---|---|---|---|---|
1 | CornerMercury | Python | 269 | 102 | 167 | 42 days ago |
2 | dbasden | C | 561 | 251 | 310 | 42 days ago |
3 | Szabolcs Dombi | Python | 10141 | 141 | - | 42 days ago |
4 | Mechazawa | JavaScript | 10206 | 206 | - | 38 days ago |
5 | Tomáš Mach | Python | 10234 | 234 | - | 42 days ago |
#include
<stdio.h>
char
grid
[
256
]
[
256
]
;
int
width
,
height
;
typedef
struct
{
int
i
;
int
j
;
}
pos_t
;
static
pos_t
elf_loc
;
static
pos_t
elf_vec
=
{
-1
,
0
}
;
int
main
(
)
{
while
(
scanf
(
"
%
s
%
n
\
n
"
,
&
(
grid
[
++
height
]
[
0
]
)
,
&
width
)
==
1
)
for
(
int
j
=
0
;
j
<=
width
;
++
j
)
if
(
grid
[
height
]
[
j
]
==
'
^
'
)
elf_loc
=
(
pos_t
)
{
height
,
j
}
;
while
(
grid
[
elf_loc
.
i
]
[
elf_loc
.
j
]
)
{
grid
[
elf_loc
.
i
]
[
elf_loc
.
j
]
=
'
X
'
;
pos_t
forward
=
(
pos_t
)
{
elf_loc
.
i
+
elf_vec
.
i
,
elf_loc
.
j
+
elf_vec
.
j
}
;
if
(
grid
[
forward
.
i
]
[
forward
.
j
]
!=
'
#
'
)
elf_loc
=
forward
;
else
elf_vec
=
(
pos_t
)
{
elf_vec
.
j
,
-
elf_vec
.
i
}
;
}
int
visited
=
0
;
for
(
int
i
=
1
;
i
<
height
;
++
i
)
for
(
int
j
=
0
;
j
<
width
;
++
j
)
visited
+=
grid
[
i
]
[
j
]
==
'
X
'
;
printf
(
"
%
d
\
n
"
,
visited
)
;
}