<?php
header("Content-Type: text/plain; charset=utf-8"); ?>
<?php
/* http://d...content-available-to-author-only...2.net/ */
SUBWAY => 'едешь на метро',
FOOT => 'идешь пешком',
BUS => 'едешь на автобусе'
);
$startPoint = 'pet'; // Петроградская
$endPoint = 'gos'; // Новая Голландия
'pet' => 'ст. м. Петроградская',
'chk' => 'ст. м. Чкаловская',
'gor' => 'ст. м. Горьковская',
'spo' => 'ст. м. Спортивная',
'vas' => 'ст. м. Василеостровская',
'kre' => 'Петропавловская крепость',
'let' => 'Летний сад',
'dvo' => 'Дворцовая площадь',
'isa' => 'Исакиевский собор',
'nov' => 'Новая Голландия',
'ras' => 'Дом Раскольникова',
'gos' => 'Гостиный Двор',
'sen' => 'Сенная Площадь',
'vla' => 'ст. м. Владимирская',
'vit' => 'Витебский вокзал',
'teh' => 'Технологический Институт'
);
'chk' => canGet(10, BUS),
'gor' => canGet(3, SUBWAY)
),
'pet' => canGet(10, BUS),
'spo' => canGet(3, SUBWAY)
),
'pet' => canGet(3, BUS),
'kre' => canGet(5, FOOT),
'gos' => canGet(6, SUBWAY)
),
'chk' => canGet(3, SUBWAY),
'vas' => canGet(10, BUS),
'sen' => canGet(7, SUBWAY)
),
'spo' => canGet(10, BUS),
'gos' => canGet(7, SUBWAY),
'nov' => canGet(11, FOOT)
),
'gor' => canGet(5, FOOT)
),
'dvo' => canGet(6, FOOT),
'gos' => canGet(7, FOOT)
),
'isa' => canGet(6, FOOT),
'gos' => canGet(6, FOOT),
'let' => canGet(6, FOOT)
),
'dvo' => canGet(6, FOOT),
'nov' => canGet(5, FOOT)
),
'vas' => canGet(11, FOOT),
'isa' => canGet(5, FOOT),
'ras' => canGet(7, BUS)
),
'nov' => canGet(7, BUS),
'sen' => canGet(3, FOOT)
),
'vas' => canGet(7, SUBWAY),
'sen' => canGet(3, SUBWAY),
'dvo' => canGet(6, FOOT),
'gor' => canGet(6, SUBWAY),
'let' => canGet(7, FOOT),
'vla' => canGet(7, FOOT)
),
'ras' => canGet(3, FOOT),
'spo' => canGet(7, SUBWAY),
'gos' => canGet(3, SUBWAY),
'vla' => canGet(4, SUBWAY),
'vit' => canGet(2, SUBWAY),
'teh' => canGet(3, SUBWAY)
),
'sen' => canGet(4, SUBWAY),
'gos' => canGet(7, FOOT),
'vit' => canGet(3, SUBWAY)
),
'sen' => canGet(2, SUBWAY),
'teh' => canGet(2, SUBWAY),
'vla' => canGet(3, SUBWAY)
),
'sen' => canGet(3, SUBWAY),
'vit' => canGet(2, SUBWAY)
)
);
/* Чтобы не писать много раз array('time' => ..., 'by' => ...), используем функцию.
«canGet» переводится как «можно попасть» */
$time = 10;
function canGet($time, $byWhat)
{
'time' => $time,
'by' => $byWhat
);
}
'teh',
'sen'
);
$target = 'dvo';
$point = 'sen';
function makeOneStep($paths, $pathDone, $point, $time, $target)
{
if (isset($paths[$point][$target])) { $result['path'] = $target;
return $result;
} else {
foreach ($paths[$point] as $k => $v) {
if (isset($paths[$k][$target])) {
$result['path'] = $k;
$result['path2'] = $target;
}
}
}
return $result;
}
$step = makeOneStep($paths, $pathDone, $point, $time, $target);
$pathDone[] = $step['path'];
if (isset($step['path2'])) { $pathDone[] = $step['path2'];
}
PD9waHAKaGVhZGVyKCJDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9dXRmLTgiKTsKPz4KCjw/cGhwCm1iX2ludGVybmFsX2VuY29kaW5nKCJVVEYtOCIpOwoKZXJyb3JfcmVwb3J0aW5nKC0xKTsKLyogaHR0cDovL2QuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLjIubmV0LyAqLwoKZGVmaW5lKCdTVUJXQVknLCAnc3ViJyk7CmRlZmluZSgnRk9PVCcsICdmb290Jyk7CmRlZmluZSgnQlVTJywgJ2J1cycpOwoKJHRyYW5zcG9ydE5hbWUgPSBhcnJheSgKICAgIFNVQldBWSA9PiAn0LXQtNC10YjRjCDQvdCwINC80LXRgtGA0L4nLAogICAgRk9PVCA9PiAn0LjQtNC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INCf0LvQvtGJ0LDQtNGMJywKICAgICd2bGEnID0+ICfRgdGCLiDQvC4g0JLQu9Cw0LTQuNC80LjRgNGB0LrQsNGPJywKICAgICd2aXQnID0+ICfQktC40YLQtdCx0YHQutC40Lkg0LLQvtC60LfQsNC7JywKICAgICd0ZWgnID0+ICfQotC10YXQvdC+0LvQvtCz0LjRh9C10YHQutC40Lkg0JjQvdGB0YLQuNGC0YPRgicKKTsKCiRwYXRocyA9IGFycmF5KAogICAgJ3BldCcgPT4gYXJyYXkoCiAgICAgICAgJ2NoaycgPT4gY2FuR2V0KDEwLCBCVVMpLAogICAgICAgICdnb3InID0+IGNhbkdldCgzLCBTVUJXQVkpCiAgICApLAogICAgCiAgICAnY2hrJyA9PiBhcnJheSgKICAgICAgICAncGV0JyA9PiBjYW5HZXQoMTAsIEJVUyksCiAgICAgICAgJ3NwbycgPT4gY2FuR2V0KDMsIFNVQldBWSkKICAgICksCiAgICAKICAgICdnb3InID0+IGFycmF5KAogICAgICAgICdwZXQnID0+IGNhbkdldCgzLCBCVVMpLAogICAgICAgICdrcmUnID0+IGNhbkdldCg1LCBGT09UKSwKICAgICAgICAnZ29zJyA9PiBjYW5HZXQoNiwgU1VCV0FZKQogICAgKSwKICAgIAogICAgJ3NwbycgPT4gYXJyYXkoCiAgICAgICAgJ2NoaycgPT4gY2FuR2V0KDMsIFNVQldBWSksCiAgICAgICAgJ3ZhcycgPT4gY2FuR2V0KDEwLCBCVVMpLAogICAgICAgICdzZW4nID0+IGNhbkdldCg3LCBTVUJXQVkpCiAgICApLAogICAgCiAgICAndmFzJyA9PiBhcnJheSgKICAgICAgICAnc3BvJyA9PiBjYW5HZXQoMTAsIEJVUyksCiAgICAgICAgJ2dvcycgPT4gY2FuR2V0KDcsIFNVQldBWSksCiAgICAgICAgJ25vdicgPT4gY2FuR2V0KDExLCBGT09UKQogICAgKSwKICAgIAogICAgJ2tyZScgPT4gYXJyYXkoCiAgICAgICAgJ2dvcicgPT4gY2FuR2V0KDUsIEZPT1QpCiAgICApLAogICAgCiAgICAnbGV0JyA9PiBhcnJheSgKICAgICAgICAnZHZvJyA9PiBjYW5HZXQoNiwgRk9PVCksCiAgICAgICAgJ2dvcycgPT4gY2FuR2V0KDcsIEZPT1QpCiAgICApLAogICAgCiAgICAnZHZvJyA9PiBhcnJheSgKICAgICAgICAnaXNhJyA9PiBjYW5HZXQoNiwgRk9PVCksCiAgICAgICAgJ2dvcycgPT4gY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdsZXQnID0+IGNhbkdldCg2LCBGT09UKQogICAgKSwKICAgIAogICAgJ2lzYScgPT4gYXJyYXkoCiAgICAgICAgJ2R2bycgPT4gY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdub3YnID0+IGNhbkdldCg1LCBGT09UKQogICAgKSwKICAgIAogICAgJ25vdicgPT4gYXJyYXkoCiAgICAgICAgJ3ZhcycgPT4gY2FuR2V0KDExLCBGT09UKSwKICAgICAgICAnaXNhJyA9PiBjYW5HZXQoNSwgRk9PVCksCiAgICAgICAgJ3JhcycgPT4gY2FuR2V0KDcsIEJVUykKICAgICksCiAgICAKICAgICdyYXMnID0+IGFycmF5KAogICAgICAgICdub3YnID0+IGNhbkdldCg3LCBCVVMpLAogICAgICAgICdzZW4nID0+IGNhbkdldCgzLCBGT09UKQogICAgKSwKICAgIAogICAgJ2dvcycgPT4gYXJyYXkoCiAgICAgICAgJ3ZhcycgPT4gY2FuR2V0KDcsIFNVQldBWSksCiAgICAgICAgJ3NlbicgPT4gY2FuR2V0KDMsIFNVQldBWSksCiAgICAgICAgJ2R2bycgPT4gY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdnb3InID0+IGNhbkdldCg2LCBTVUJXQVkpLAogICAgICAgICdsZXQnID0+IGNhbkdldCg3LCBGT09UKSwKICAgICAgICAndmxhJyA9PiBjYW5HZXQoNywgRk9PVCkKICAgICksCiAgICAKICAgICdzZW4nID0+IGFycmF5KAogICAgICAgICdyYXMnID0+IGNhbkdldC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