-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-b.ldpl
47 lines (40 loc) · 851 Bytes
/
06-b.ldpl
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
39
40
41
42
43
44
45
46
47
data:
auxText is text
lines is text list
orbit is text list
adjacents is text list map
explored is number map
result is number
procedure:
load file "06.txt" in auxText
split auxText by crlf in lines
delete last element of lines
for each auxText in lines do
split auxText by ")" in orbit
push orbit:0 to adjacents:orbit:1
push orbit:1 to adjacents:orbit:0
repeat
store -1 in result
call findSanta with "YOU"
sub findSanta
parameters:
planet is text
local data:
planetAux is text
procedure:
if explored:planet is equal to 1 then
return
end if
store 1 in explored:planet
for each planetAux in adjacents:planet do
if planetAux is equal to "SAN" then
display result crlf
exit
else
in result solve result + 1
call findSanta with planetAux
in result solve result - 1
end if
repeat
end sub
display result crlf