<?php
/* http://d...content-available-to-author-only...2.net/ */
SUBWAY => 'едешь на метро',
FOOT => 'идешь пешком',
BUS => 'едешь на автобусе'
);
'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» переводится как «можно попасть» */
function canGet($time, $byWhat) {
return array('time' => $time, 'by' => $byWhat); }
function makeOneStep($paths, $pathDone, $time, $point, $target) {
if(isset($paths[$point][$target])) { $result = [];
$time += $paths[$point][$target]['time'];
$result['time'] = $time;
$pathDone[] = $target;
$result['path'] = $pathDone;
return $result;
}
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Ci8qIGh0dHA6Ly9kLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi4yLm5ldC8gKi8KCmRlZmluZSgnU1VCV0FZJywgJ3N1YicpOwpkZWZpbmUoJ0ZPT1QnLCAnZm9vdCcpOwpkZWZpbmUoJ0JVUycsICdidXMnKTsKCiR0cmFuc3BvcnROYW1lID0gYXJyYXkoCiAgICBTVUJXQVkgID0+ICAn0LXQtNC10YjRjCDQvdCwINC80LXRgtGA0L4nLAogICAgRk9PVCAgICA9PiAgJ9C40LTQtdGI0Ywg0L/QtdGI0LrQvtC8JywKICAgIEJVUyAgICAgPT4gICfQtdC00LXRiNGMINC90LAg0LDQstGC0L7QsdGD0YHQtScKKTsKCiRwb2ludE5hbWVzID0gYXJyYXkoCiAgICAncGV0JyAgID0+ICAn0YHRgi4g0LwuINCf0LXRgtGA0L7Qs9GA0LDQtNGB0LrQsNGPJywKICAgICdjaGsnICAgPT4gICfRgdGCLiDQvC4g0KfQutCw0LvQvtCy0YHQutCw0Y8nLAogICAgJ2dvcicgICA9PiAgJ9GB0YIuINC8LiDQk9C+0YDRjNC60L7QstGB0LrQsN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AgYXJyYXkoCiAgICAgICAgJ3BldCcgICA9PiAgY2FuR2V0KDEwLCBCVVMpLAogICAgICAgICdzcG8nICAgPT4gIGNhbkdldCgzLCBTVUJXQVkpCiAgICApLAoKICAgICdnb3InICAgPT4gIGFycmF5KAogICAgICAgICdwZXQnICAgPT4gIGNhbkdldCgzLCBCVVMpLAogICAgICAgICdrcmUnICAgPT4gIGNhbkdldCg1LCBGT09UKSwKICAgICAgICAnZ29zJyAgID0+ICBjYW5HZXQoNiwgU1VCV0FZKQogICAgKSwKCiAgICAnc3BvJyAgID0+ICBhcnJheSgKICAgICAgICAnY2hrJyAgID0+ICBjYW5HZXQoMywgU1VCV0FZKSwKICAgICAgICAndmFzJyAgID0+ICBjYW5HZXQoMTAsIEJVUyksCiAgICAgICAgJ3NlbicgICA9PiAgY2FuR2V0KDcsIFNVQldBWSkKICAgICksCgogICAgJ3ZhcycgICA9PiAgYXJyYXkoCiAgICAgICAgJ3NwbycgICA9PiAgY2FuR2V0KDEwLCBCVVMpLAogICAgICAgICdnb3MnICAgPT4gIGNhbkdldCg3LCBTVUJXQVkpLAogICAgICAgICdub3YnICAgPT4gIGNhbkdldCgxMSwgRk9PVCkKICAgICksCgogICAgJ2tyZScgICA9PiAgYXJyYXkoCiAgICAgICAgJ2dvcicgICA9PiAgY2FuR2V0KDUsIEZPT1QpCiAgICApLAoKICAgICdsZXQnICAgPT4gIGFycmF5KAogICAgICAgICdkdm8nICAgPT4gIGNhbkdldCg2LCBGT09UKSwKICAgICAgICAnZ29zJyAgID0+ICBjYW5HZXQoNywgRk9PVCkKICAgICksCgogICAgJ2R2bycgICA9PiAgYXJyYXkoCiAgICAgICAgJ2lzYScgICA9PiAgY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdnb3MnICAgPT4gIGNhbkdldCg2LCBGT09UKSwKICAgICAgICAnbGV0JyAgID0+ICBjYW5HZXQoNiwgRk9PVCkKICAgICksCgogICAgJ2lzYScgICA9PiAgYXJyYXkoCiAgICAgICAgJ2R2bycgICA9PiAgY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdub3YnICAgPT4gIGNhbkdldCg1LCBGT09UKQogICAgKSwKCiAgICAnbm92JyAgID0+ICBhcnJheSgKICAgICAgICAndmFzJyAgID0+ICBjYW5HZXQoMTEsIEZPT1QpLAogICAgICAgICdpc2EnICAgPT4gIGNhbkdldCg1LCBGT09UKSwKICAgICAgICAncmFzJyAgID0+ICBjYW5HZXQoNywgQlVTKQogICAgKSwKCiAgICAncmFzJyAgID0+ICBhcnJheSgKICAgICAgICAnbm92JyAgID0+ICBjYW5HZXQoNywgQlVTKSwKICAgICAgICAnc2VuJyAgID0+ICBjYW5HZXQoMywgRk9PVCkKICAgICksCgogICAgJ2dvcycgICA9PiAgYXJyYXkoCiAgICAgICAgJ3ZhcycgICA9PiAgY2FuR2V0KDcsIFNVQldBWSksCiAgICAgICAgJ3NlbicgICA9PiAgY2FuR2V0KDMsIFNVQldBWSksCiAgICAgICAgJ2R2bycgICA9PiAgY2FuR2V0KDYsIEZPT1QpLAogICAgICAgICdnb3InICAgPT4gIGNhbkdldCg2LCBTVUJXQVkpLAogICAgICAgICdsZXQnICAgPT4gIGNhbkdldCg3LCBGT09UKSwKICAgICAgICAndmxhJyAgID0+ICBjYW5HZXQoNywgRk9PVCkgICAgICAgIAogICAgKSwKCiAgICAnc2VuJyAgID0+ICBhcnJheSgKICAgICAgICAncmFzJyAgID0+ICBjYW5HZXQoMywgRk9PVCksCiAgICAgICAgJ3NwbycgICA9PiAgY2FuR2V0KDcsIFNVQldBWSksCiAgICAgICAgJ2dvcycgICA9PiAgY2FuR2V0KDMsIFNVQldBWSksCiAgICAgICAgJ3ZsYScgICA9PiAgY2FuR2V0KDQsIFNVQldBWSksCiAgICAgICAgJ3ZpdCcgICA9PiAgY2FuR2V0KDIsIFNVQldBWSksCiAgICAgICAgJ3RlaCcgICA9PiAgY2FuR2V0KDMsIFNVQldBWSkKICAgICksCgogICAgJ3ZsYScgICA9PiAgYX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