19 lines
508 B
Text
19 lines
508 B
Text
on getCommonPath (pathes, sep)
|
|
_player.itemDelimiter = sep
|
|
|
|
-- find length of shortest path (in terms of items)
|
|
commonCnt = the maxInteger
|
|
repeat with p in pathes
|
|
if p.item.count<commonCnt then commonCnt=p.item.count
|
|
end repeat
|
|
|
|
pathCnt = pathes.count
|
|
repeat with i = 1 to commonCnt
|
|
repeat with j = 2 to pathCnt
|
|
if pathes[j].item[i]<>pathes[j-1].item[i] then
|
|
return pathes[1].item[1..i-1]
|
|
end if
|
|
end repeat
|
|
end repeat
|
|
return pathes[1].item[1..commonCnt]
|
|
end
|