Codegolf - Где-То В Метро... Но На Каких Линиях?

  • Автор темы Alxbel
  • Обновлено
  • 20, Oct 2024
  • #1

Лондонское метро, ​​известное как Трубка является старейшей подземной железной дорогой в мире, в настоящее время она состоит из одиннадцати линий*, обслуживающих 267 названных станций (строго 269** станций, поскольку «Эджвер-роуд» и «Хаммерсмит» занимают по две станции каждая)

Задача

Выведите названия линий, обслуживающих станцию, заданную в качестве входных данных.

Вход:
Строка или список символов

  • Можно предположить, что это действительный название станции (как указано в кодовом блоке ниже).

  • Вы можете предположить любое

     
     Bakerloo
    Central
    Circle
    District
    Hammersmith & City
    Jubilee
    Metropolitan
    Northern
    Piccadilly
    Victoria
    Waterloo & City
     
    in the input will последовательно быть словом Input (Station Name) : Output (list of tube line names) ---------------------------------------------------------------------------------------------------------------- "Acton Town" : ["District","Piccadilly"] "Aldgate" : ["Circle","Metropolitan"] "Aldgate East" : ["District","Hammersmith & City"] "Alperton" : ["Piccadilly"] "Amersham" : ["Metropolitan"] "Angel" : ["Northern"] "Archway" : ["Northern"] "Arnos Grove" : ["Piccadilly"] "Arsenal" : ["Piccadilly"] "Baker Street" : ["Bakerloo","Circle","Hammersmith & City","Jubilee","Metropolitan"] "Balham" : ["Northern"] "Bank" : ["Central","Northern","Waterloo & City"] "Barbican" : ["Circle","Hammersmith & City","Metropolitan"] "Barking" : ["District","Hammersmith & City"] "Barkingside" : ["Central"] "Barons Court" : ["District","Piccadilly"] "Bayswater" : ["Circle","District"] "Becontree" : ["District"] "Belsize Park" : ["Northern"] "Bermondsey" : ["Jubilee"] "Bethnal Green" : ["Central"] "Blackfriars" : ["Circle","District"] "Blackhorse Road" : ["Victoria"] "Bond Street" : ["Central","Jubilee"] "Borough" : ["Northern"] "Boston Manor" : ["Piccadilly"] "Bounds Green" : ["Piccadilly"] "Bow Road" : ["District","Hammersmith & City"] "Brent Cross" : ["Northern"] "Brixton" : ["Victoria"] "Bromley-by-Bow" : ["District","Hammersmith & City"] "Buckhurst Hill" : ["Central"] "Burnt Oak" : ["Northern"] "Caledonian Road" : ["Piccadilly"] "Camden Town" : ["Northern"] "Canada Water" : ["Jubilee"] "Canary Wharf" : ["Jubilee"] "Canning Town" : ["Jubilee"] "Cannon Street" : ["Circle","District"] "Canons Park" : ["Jubilee"] "Chalfont & Latimer" : ["Metropolitan"] "Chalk Farm" : ["Northern"] "Chancery Lane" : ["Central"] "Charing Cross" : ["Bakerloo","Northern"] "Chesham" : ["Metropolitan"] "Chigwell" : ["Central"] "Chiswick Park" : ["District"] "Chorleywood" : ["Metropolitan"] "Clapham Common" : ["Northern"] "Clapham North" : ["Northern"] "Clapham South" : ["Northern"] "Cockfosters" : ["Piccadilly"] "Colindale" : ["Northern"] "Colliers Wood" : ["Northern"] "Covent Garden" : ["Piccadilly"] "Croxley" : ["Metropolitan"] "Dagenham East" : ["District"] "Dagenham Heathway" : ["District"] "Debden" : ["Central"] "Dollis Hill" : ["Jubilee"] "Ealing Broadway" : ["Central","District"] "Ealing Common" : ["District","Piccadilly"] "Earl's Court" : ["District","Piccadilly"] "East Acton" : ["Central"] "East Finchley" : ["Northern"] "East Ham" : ["District","Hammersmith & City"] "East Putney" : ["District"] "Eastcote" : ["Metropolitan","Piccadilly"] "Edgware" : ["Northern"] "Edgware Road" : ["Bakerloo","Circle","District","Hammersmith & City"] "Elephant & Castle" : ["Bakerloo","Northern"] "Elm Park" : ["District"] "Embankment" : ["Bakerloo","Circle","District","Northern"] "Epping" : ["Central"] "Euston" : ["Northern","Victoria"] "Euston Square" : ["Circle","Hammersmith & City","Metropolitan"] "Fairlop" : ["Central"] "Farringdon" : ["Circle","Hammersmith & City","Metropolitan"] "Finchley Central" : ["Northern"] "Finchley Road" : ["Jubilee","Metropolitan"] "Finsbury Park" : ["Piccadilly","Victoria"] "Fulham Broadway" : ["District"] "Gants Hill" : ["Central"] "Gloucester Road" : ["Circle","District","Piccadilly"] "Golders Green" : ["Northern"] "Goldhawk Road" : ["Circle","Hammersmith & City"] "Goodge Street" : ["Northern"] "Grange Hill" : ["Central"] "Great Portland Street" : ["Circle","Hammersmith & City","Metropolitan"] "Greenford" : ["Central"] "Green Park" : ["Jubilee","Piccadilly","Victoria"] "Gunnersbury" : ["District"] "Hainault" : ["Central"] "Hammersmith" : ["Circle","District","Hammersmith & City","Piccadilly"] "Hampstead" : ["Northern"] "Hanger Lane" : ["Central"] "Harlesden" : ["Bakerloo"] "Harrow & Wealdstone" : ["Bakerloo"] "Harrow-on-the-Hill" : ["Metropolitan"] "Hatton Cross" : ["Piccadilly"] "Heathrow Terminals 1, 2, 3" : ["Piccadilly"] "Heathrow Terminal 4" : ["Piccadilly"] "Heathrow Terminal 5" : ["Piccadilly"] "Hendon Central" : ["Northern"] "High Barnet" : ["Northern"] "Highbury & Islington" : ["Victoria"] "Highgate" : ["Northern"] "High Street Kensington" : ["Circle","District"] "Hillingdon" : ["Metropolitan","Piccadilly"] "Holborn" : ["Central","Piccadilly"] "Holland Park" : ["Central"] "Holloway Road" : ["Piccadilly"] "Hornchurch" : ["District"] "Hounslow Central" : ["Piccadilly"] "Hounslow East" : ["Piccadilly"] "Hounslow West" : ["Piccadilly"] "Hyde Park Corner" : ["Piccadilly"] "Ickenham" : ["Metropolitan","Piccadilly"] "Kennington" : ["Northern"] "Kensal Green" : ["Bakerloo"] "Kensington (Olympia)" : ["District"] "Kentish Town" : ["Northern"] "Kenton" : ["Bakerloo"] "Kew Gardens" : ["District"] "Kilburn" : ["Jubilee"] "Kilburn Park" : ["Bakerloo"] "Kingsbury" : ["Jubilee"] "King's Cross St. Pancras" : ["Circle","Hammersmith & City","Metropolitan","Northern","Piccadilly","Victoria"] "Knightsbridge" : ["Piccadilly"] "Ladbroke Grove" : ["Circle","Hammersmith & City"] "Lambeth North" : ["Bakerloo"] "Lancaster Gate" : ["Central"] "Latimer Road" : ["Circle","Hammersmith & City"] "Leicester Square" : ["Northern","Piccadilly"] "Leyton" : ["Central"] "Leytonstone" : ["Central"] "Liverpool Street" : ["Central","Circle","Hammersmith & City","Metropolitan"] "London Bridge" : ["Jubilee","Northern"] "Loughton" : ["Central"] "Maida Vale" : ["Bakerloo"] "Manor House" : ["Piccadilly"] "Mansion House" : ["Circle","District"] "Marble Arch" : ["Central"] "Marylebone" : ["Bakerloo"] "Mile End" : ["Central","District","Hammersmith & City"] "Mill Hill East" : ["Northern"] "Monument" : ["Circle","District"] "Moorgate" : ["Circle","Hammersmith & City","Metropolitan","Northern"] "Moor Park" : ["Metropolitan"] "Morden" : ["Northern"] "Mornington Crescent" : ["Northern"] "Neasden" : ["Jubilee"] "Newbury Park" : ["Central"] "North Acton" : ["Central"] "North Ealing" : ["Piccadilly"] "North Greenwich" : ["Jubilee"] "North Harrow" : ["Metropolitan"] "North Wembley" : ["Bakerloo"] "Northfields" : ["Piccadilly"] "Northolt" : ["Central"] "Northwick Park" : ["Metropolitan"] "Northwood" : ["Metropolitan"] "Northwood Hills" : ["Metropolitan"] "Notting Hill Gate" : ["Central","Circle","District"] "Oakwood" : ["Piccadilly"] "Old Street" : ["Northern"] "Osterley" : ["Piccadilly"] "Oval" : ["Northern"] "Oxford Circus" : ["Bakerloo","Central","Victoria"] "Paddington" : ["Bakerloo","Circle","District","Hammersmith & City"] "Park Royal" : ["Piccadilly"] "Parsons Green" : ["District"] "Perivale" : ["Central"] "Piccadilly Circus" : ["Bakerloo","Piccadilly"] "Pimlico" : ["Victoria"] "Pinner" : ["Metropolitan"] "Plaistow" : ["District","Hammersmith & City"] "Preston Road" : ["Metropolitan"] "Putney Bridge" : ["District"] "Queen's Park" : ["Bakerloo"] "Queensbury" : ["Jubilee"] "Queensway" : ["Central"] "Ravenscourt Park" : ["District"] "Rayners Lane" : ["Metropolitan","Piccadilly"] "Redbridge" : ["Central"] "Regent's Park" : ["Bakerloo"] "Richmond" : ["District"] "Rickmansworth" : ["Metropolitan"] "Roding Valley" : ["Central"] "Royal Oak" : ["Circle","Hammersmith & City"] "Ruislip" : ["Metropolitan","Piccadilly"] "Ruislip Gardens" : ["Central"] "Ruislip Manor" : ["Metropolitan","Piccadilly"] "Russell Square" : ["Piccadilly"] "St. James's Park" : ["Circle","District"] "St. John's Wood" : ["Jubilee"] "St. Paul's" : ["Central"] "Seven Sisters" : ["Victoria"] "Shepherd's Bush" : ["Central"] "Shepherd's Bush Market" : ["Circle","Hammersmith & City"] "Sloane Square" : ["Circle","District"] "Snaresbrook" : ["Central"] "South Ealing" : ["Piccadilly"] "South Harrow" : ["Piccadilly"] "South Kensington" : ["Circle","District","Piccadilly"] "South Kenton" : ["Bakerloo"] "South Ruislip" : ["Central"] "South Wimbledon" : ["Northern"] "South Woodford" : ["Central"] "Southfields" : ["District"] "Southgate" : ["Piccadilly"] "Southwark" : ["Jubilee"] "Stamford Brook" : ["District"] "Stanmore" : ["Jubilee"] "Stepney Green" : ["District","Hammersmith & City"] "Stockwell" : ["Northern","Victoria"] "Stonebridge Park" : ["Bakerloo"] "Stratford" : ["Central","Jubilee"] "Sudbury Hill" : ["Piccadilly"] "Sudbury Town" : ["Piccadilly"] "Swiss Cottage" : ["Jubilee"] "Temple" : ["Circle","District"] "Theydon Bois" : ["Central"] "Tooting Bec" : ["Northern"] "Tooting Broadway" : ["Northern"] "Tottenham Court Road" : ["Central","Northern"] "Tottenham Hale" : ["Victoria"] "Totteridge & Whetstone" : ["Northern"] "Tower Hill" : ["Circle","District"] "Tufnell Park" : ["Northern"] "Turnham Green" : ["District","Piccadilly"] "Turnpike Lane" : ["Piccadilly"] "Upminster" : ["District"] "Upminster Bridge" : ["District"] "Upney" : ["District"] "Upton Park" : ["District","Hammersmith & City"] "Uxbridge" : ["Metropolitan","Piccadilly"] "Vauxhall" : ["Victoria"] "Victoria" : ["Circle","District","Victoria"] "Walthamstow Central" : ["Victoria"] "Wanstead" : ["Central"] "Warren Street" : ["Northern","Victoria"] "Warwick Avenue" : ["Bakerloo"] "Waterloo" : ["Bakerloo","Jubilee","Northern","Waterloo & City"] "Watford" : ["Metropolitan"] "Wembley Central" : ["Bakerloo"] "Wembley Park" : ["Jubilee","Metropolitan"] "West Acton" : ["Central"] "West Brompton" : ["District"] "West Finchley" : ["Northern"] "West Ham" : ["District","Hammersmith & City","Jubilee"] "West Hampstead" : ["Jubilee"] "West Harrow" : ["Metropolitan"] "West Kensington" : ["District"] "West Ruislip" : ["Central"] "Westbourne Park" : ["Circle","Hammersmith & City"] "Westminster" : ["Circle","District","Jubilee"] "White City" : ["Central"] "Whitechapel" : ["District","Hammersmith & City"] "Willesden Green" : ["Jubilee"] "Willesden Junction" : ["Bakerloo"] "Wimbledon" : ["District"] "Wimbledon Park" : ["District"] "Wood Green" : ["Piccadilly"] "Wood Lane" : ["Circle","Hammersmith & City"] "Woodford" : ["Central"] "Woodside Park" : ["Northern"] (or And ) вместо этого, если хотите, просто четко укажите это в своем ответе.

Выход:
Отдельный выходные данные, в которых перечислены одиннадцать линий, обслуживающих эту станцию:

  • Список строк, список списков символов, печатный текст, строка, список символов; если сомневаешься, спроси.

  • Вы можете последовательно вывести слово and (or & ) вместо любого & if you wish, just state this clearly in your answer.

  • С оговоркой, что при печати или возврате строки или списка символов, используемая подстрока-разделитель, не присутствует ни в одном из имен строк (включая And или and or And used) - this therefore excludes the use of a single space character as the separator.

Сеть метро:
- Примечание. Это окончательное состояние, даже если оно содержит орфографическую ошибку (если она не устранена до каких-либо ответов).

and

...одиннадцать названий строк:

&

* Транспорт Лондона также управляет другими железнодорожными линиями, некоторые из которых также можно назвать частью «Метро» (скорее всего, «Доклендская легкая железная дорога» или «DLR»), но мы будем придерживаться одиннадцати, перечисленных здесь.

** На связанной странице Википедии в настоящее время указано 270, но я считаю, что они ошибочно считают второе место в Кэнэри-Уорф, хотя оно обслуживает только «DLR»).


Куча воображаемых очков (и, скорее всего, также много голосов «за») за подачу в гольф с использованием Морнингтон-Кресент (доступна совместимая IDE здесь)!


Это так, поэтому побеждает самый короткий код в байтах для каждого языка и самое короткое решение (не позволяйте языкам для игры в гольф отпугнуть вас от игры в гольф на других языках). Веселиться!

#код-гольф #код-гольф #теория графов #сжатие

Alxbel


Рег
21 May, 2005

Тем
83

Постов
209

Баллов
644
  • 26, Oct 2024
  • #2

Математика 8+, 266 байт

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 var v:(String)->List<String> =
{x->d("eJw1VcluG0cU/BWfchoC/dbuPpJDkTM2EuSUnGmFgIlQYkAzBwNEvj1VrUSHkXp7S1W90v7y/XG/vD6ev15eX09/XK7XH8/5cn+9np8/nx/321+36+Vxen8up7e38/372+Xx7dNPn+bL48fzl9v98e18f3/uTn+e79fb7fn576+X6/n8nM/vj/vp+vz99BgH/7/4DYlu98vpH83i290k0vq8nzbqptuXSa3GDiurbT+JRztMKpUf0R1OJXdTtnKcX5b9pKXgpOZ6+Dxtsuf8sp/MEGWjEm3FURSmcI15O0npvmWiKofJsyx447FyR43nKvYFqyzrMmkIUieTilZHSWHOyJKdz0vFVamNJUvKih0/YKfpKN9RsnRfpm4LWqyJb6uKLBuxjtXGiqJr6YFobLeujOfliGV0Nh8dYcOCb9KEGJnmYWoNmTIISiorE5eRuzZlLLWOTQu8qK1tJ9XM8dUVNfWO5sR0JRQ1ScFGo/Xx24yoZesMJzH6tdJ5Nb3vmas3Y+Iex5nHJhUVS5XKMqtxG2svhYGA9Bdk64XMqBQj2qU3LpGtoJtNV1u4Kt53hL8lam7BYpsDMfInLEhrj/ll6sR/g1gMJmo+gkk6MloujBHRtuNKR5AUFIogNYLvPJP3ypF9xnEyD5TW2Jo0cCcZMr5g3itwlRIDDlNH6E5irTmYbN2JiIesu6lmjHLaiORVWQDYJRNDPlpMRpIsu8FVw2M0CzAhvyOCCrkikRresZFppM0r1SK8gl4Wihow7A9oFKSw4t6IC6lJPiuoRD1y7GUtB+ZTUc6DDL1H2PpBAdS8sDkOEdVbEQGBMjhrBcihgHGk0OSRnPW2Dllo16E5Slobs+3JezWSAaaGqttoRyG5WsiFilMWSUCMSsTwB+uI6ojuzZCX1eGgyKC10wZq3ZOusv43QOwoGoYfMs/BLX2ilX5cqTetQ5xaGm6COIyQVMU0SSnliBQlOelmZT+1xE1Ahz+lqw/dBFsVVaC9aYbJNAcV8B7yjWahNMekkmgYDLzEhoFRgVI+yMCoDoITvaDTMTphOoSgA7ToIFbHSAh1j9nhn70630MCtKTGMbACOsKSegHQW2KUkG7PD9OoAFuUVTXHGGoRtJ0C9/EmCAKVLBxJGc7opWMooS5QbfCBhUmdkIK84V3FuYffo8wykmTHEGAg+XX43fC6RhNshUY5WrIwXhJBiSbUuduwXKuUcqdHELHhGzEw8cBUpbR5SwxKxSqcTCEUHVYDwvemx4UeH07TtKFSaEZgHKjTqCmFx/U6DLAq/gcs7EQaZ4cKElpgaUPk1ohw7Rhi3sIPB8Y6hTBgA7Ve6buBVgBSxXyH4RHm1RkCW4d/AeEEm1Q=").split("~").w{v ->Regex("(-?[0-9]+)([A-Z]+)").findAll(v[1]).f{x.hashCode()%2897==b.groupValues[1].toInt()}.m{b.groupValues[2].m{v[0].split("|")[b-'A']}}.first()}}
data class Test(val input0: String, val output: List<String>)

val tests = listOf<Test>(

Test("""Acton Town""",listOf("""District""","""Piccadilly""")),

Test("""Aldgate""",listOf("""Circle""","""Metropolitan""")),

Test("""Aldgate East""",listOf("""District""","""Hammersmith & City""")),

Test("""Alperton""",listOf("""Piccadilly""")),

Test("""Amersham""",listOf("""Metropolitan""")),

Test("""Angel""",listOf("""Northern""")),

Test("""Archway""",listOf("""Northern""")),

Test("""Arnos Grove""",listOf("""Piccadilly""")),

Test("""Arsenal""",listOf("""Piccadilly""")),

Test("""Baker Street""",listOf("""Bakerloo""","""Circle""","""Hammersmith & City""","""Jubilee""","""Metropolitan""")),

Test("""Balham""",listOf("""Northern""")),

Test("""Bank""",listOf("""Central""","""Northern""","""Waterloo & City""")),

Test("""Barbican""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""")),

Test("""Barking""",listOf("""District""","""Hammersmith & City""")),

Test("""Barkingside""",listOf("""Central""")),

Test("""Barons Court""",listOf("""District""","""Piccadilly""")),

Test("""Bayswater""",listOf("""Circle""","""District""")),

Test("""Becontree""",listOf("""District""")),

Test("""Belsize Park""",listOf("""Northern""")),

Test("""Bermondsey""",listOf("""Jubilee""")),

Test("""Bethnal Green""",listOf("""Central""")),

Test("""Blackfriars""",listOf("""Circle""","""District""")),

Test("""Blackhorse Road""",listOf("""Victoria""")),

Test("""Bond Street""",listOf("""Central""","""Jubilee""")),

Test("""Borough""",listOf("""Northern""")),

Test("""Boston Manor""",listOf("""Piccadilly""")),

Test("""Bounds Green""",listOf("""Piccadilly""")),

Test("""Bow Road""",listOf("""District""","""Hammersmith & City""")),

Test("""Brent Cross""",listOf("""Northern""")),

Test("""Brixton""",listOf("""Victoria""")),

Test("""Bromley-by-Bow""",listOf("""District""","""Hammersmith & City""")),

Test("""Buckhurst Hill""",listOf("""Central""")),

Test("""Burnt Oak""",listOf("""Northern""")),

Test("""Caledonian Road""",listOf("""Piccadilly""")),

Test("""Camden Town""",listOf("""Northern""")),

Test("""Canada Water""",listOf("""Jubilee""")),

Test("""Canary Wharf""",listOf("""Jubilee""")),

Test("""Canning Town""",listOf("""Jubilee""")),

Test("""Cannon Street""",listOf("""Circle""","""District""")),

Test("""Canons Park""",listOf("""Jubilee""")),

Test("""Chalfont & Latimer""",listOf("""Metropolitan""")),

Test("""Chalk Farm""",listOf("""Northern""")),

Test("""Chancery Lane""",listOf("""Central""")),

Test("""Charing Cross""",listOf("""Bakerloo""","""Northern""")),

Test("""Chesham""",listOf("""Metropolitan""")),

Test("""Chigwell""",listOf("""Central""")),

Test("""Chiswick Park""",listOf("""District""")),

Test("""Chorleywood""",listOf("""Metropolitan""")),

Test("""Clapham Common""",listOf("""Northern""")),

Test("""Clapham North""",listOf("""Northern""")),

Test("""Clapham South""",listOf("""Northern""")),

Test("""Cockfosters""",listOf("""Piccadilly""")),

Test("""Colindale""",listOf("""Northern""")),

Test("""Colliers Wood""",listOf("""Northern""")),

Test("""Covent Garden""",listOf("""Piccadilly""")),

Test("""Croxley""",listOf("""Metropolitan""")),

Test("""Dagenham East""",listOf("""District""")),

Test("""Dagenham Heathway""",listOf("""District""")),

Test("""Debden""",listOf("""Central""")),

Test("""Dollis Hill""",listOf("""Jubilee""")),

Test("""Ealing Broadway""",listOf("""Central""","""District""")),

Test("""Ealing Common""",listOf("""District""","""Piccadilly""")),

Test("""Earl's Court""",listOf("""District""","""Piccadilly""")),

Test("""East Acton""",listOf("""Central""")),

Test("""East Finchley""",listOf("""Northern""")),

Test("""East Ham""",listOf("""District""","""Hammersmith & City""")),

Test("""East Putney""",listOf("""District""")),

Test("""Eastcote""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Edgware""",listOf("""Northern""")),

Test("""Edgware Road""",listOf("""Bakerloo""","""Circle""","""District""","""Hammersmith & City""")),

Test("""Elephant & Castle""",listOf("""Bakerloo""","""Northern""")),

Test("""Elm Park""",listOf("""District""")),

Test("""Embankment""",listOf("""Bakerloo""","""Circle""","""District""","""Northern""")),

Test("""Epping""",listOf("""Central""")),

Test("""Euston""",listOf("""Northern""","""Victoria""")),

Test("""Euston Square""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""")),

Test("""Fairlop""",listOf("""Central""")),

Test("""Farringdon""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""")),

Test("""Finchley Central""",listOf("""Northern""")),

Test("""Finchley Road""",listOf("""Jubilee""","""Metropolitan""")),

Test("""Finsbury Park""",listOf("""Piccadilly""","""Victoria""")),

Test("""Fulham Broadway""",listOf("""District""")),

Test("""Gants Hill""",listOf("""Central""")),

Test("""Gloucester Road""",listOf("""Circle""","""District""","""Piccadilly""")),

Test("""Golders Green""",listOf("""Northern""")),

Test("""Goldhawk Road""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Goodge Street""",listOf("""Northern""")),

Test("""Grange Hill""",listOf("""Central""")),

Test("""Great Portland Street""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""")),

Test("""Greenford""",listOf("""Central""")),

Test("""Green Park""",listOf("""Jubilee""","""Piccadilly""","""Victoria""")),

Test("""Gunnersbury""",listOf("""District""")),

Test("""Hainault""",listOf("""Central""")),

Test("""Hammersmith""",listOf("""Circle""","""District""","""Hammersmith & City""","""Piccadilly""")),

Test("""Hampstead""",listOf("""Northern""")),

Test("""Hanger Lane""",listOf("""Central""")),

Test("""Harlesden""",listOf("""Bakerloo""")),

Test("""Harrow & Wealdstone""",listOf("""Bakerloo""")),

Test("""Harrow-on-the-Hill""",listOf("""Metropolitan""")),

Test("""Hatton Cross""",listOf("""Piccadilly""")),

Test("""Heathrow Terminals 1, 2, 3""",listOf("""Piccadilly""")),

Test("""Heathrow Terminal 4""",listOf("""Piccadilly""")),

Test("""Heathrow Terminal 5""",listOf("""Piccadilly""")),

Test("""Hendon Central""",listOf("""Northern""")),

Test("""High Barnet""",listOf("""Northern""")),

Test("""Highbury & Islington""",listOf("""Victoria""")),

Test("""Highgate""",listOf("""Northern""")),

Test("""High Street Kensington""",listOf("""Circle""","""District""")),

Test("""Hillingdon""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Holborn""",listOf("""Central""","""Piccadilly""")),

Test("""Holland Park""",listOf("""Central""")),

Test("""Holloway Road""",listOf("""Piccadilly""")),

Test("""Hornchurch""",listOf("""District""")),

Test("""Hounslow Central""",listOf("""Piccadilly""")),

Test("""Hounslow East""",listOf("""Piccadilly""")),

Test("""Hounslow West""",listOf("""Piccadilly""")),

Test("""Hyde Park Corner""",listOf("""Piccadilly""")),

Test("""Ickenham""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Kennington""",listOf("""Northern""")),

Test("""Kensal Green""",listOf("""Bakerloo""")),

Test("""Kensington (Olympia)""",listOf("""District""")),

Test("""Kentish Town""",listOf("""Northern""")),

Test("""Kenton""",listOf("""Bakerloo""")),

Test("""Kew Gardens""",listOf("""District""")),

Test("""Kilburn""",listOf("""Jubilee""")),

Test("""Kilburn Park""",listOf("""Bakerloo""")),

Test("""Kingsbury""",listOf("""Jubilee""")),

Test("""King's Cross St. Pancras""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""","""Northern""","""Piccadilly""","""Victoria""")),

Test("""Knightsbridge""",listOf("""Piccadilly""")),

Test("""Ladbroke Grove""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Lambeth North""",listOf("""Bakerloo""")),

Test("""Lancaster Gate""",listOf("""Central""")),

Test("""Latimer Road""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Leicester Square""",listOf("""Northern""","""Piccadilly""")),

Test("""Leyton""",listOf("""Central""")),

Test("""Leytonstone""",listOf("""Central""")),

Test("""Liverpool Street""",listOf("""Central""","""Circle""","""Hammersmith & City""","""Metropolitan""")),

Test("""London Bridge""",listOf("""Jubilee""","""Northern""")),

Test("""Loughton""",listOf("""Central""")),

Test("""Maida Vale""",listOf("""Bakerloo""")),

Test("""Manor House""",listOf("""Piccadilly""")),

Test("""Mansion House""",listOf("""Circle""","""District""")),

Test("""Marble Arch""",listOf("""Central""")),

Test("""Marylebone""",listOf("""Bakerloo""")),

Test("""Mile End""",listOf("""Central""","""District""","""Hammersmith & City""")),

Test("""Mill Hill East""",listOf("""Northern""")),

Test("""Monument""",listOf("""Circle""","""District""")),

Test("""Moorgate""",listOf("""Circle""","""Hammersmith & City""","""Metropolitan""","""Northern""")),

Test("""Moor Park""",listOf("""Metropolitan""")),

Test("""Morden""",listOf("""Northern""")),

Test("""Mornington Crescent""",listOf("""Northern""")),

Test("""Neasden""",listOf("""Jubilee""")),

Test("""Newbury Park""",listOf("""Central""")),

Test("""North Acton""",listOf("""Central""")),

Test("""North Ealing""",listOf("""Piccadilly""")),

Test("""North Greenwich""",listOf("""Jubilee""")),

Test("""North Harrow""",listOf("""Metropolitan""")),

Test("""North Wembley""",listOf("""Bakerloo""")),

Test("""Northfields""",listOf("""Piccadilly""")),

Test("""Northolt""",listOf("""Central""")),

Test("""Northwick Park""",listOf("""Metropolitan""")),

Test("""Northwood""",listOf("""Metropolitan""")),

Test("""Northwood Hills""",listOf("""Metropolitan""")),

Test("""Notting Hill Gate""",listOf("""Central""","""Circle""","""District""")),

Test("""Oakwood""",listOf("""Piccadilly""")),

Test("""Old Street""",listOf("""Northern""")),

Test("""Osterley""",listOf("""Piccadilly""")),

Test("""Oval""",listOf("""Northern""")),

Test("""Oxford Circus""",listOf("""Bakerloo""","""Central""","""Victoria""")),

Test("""Paddington""",listOf("""Bakerloo""","""Circle""","""District""","""Hammersmith & City""")),

Test("""Park Royal""",listOf("""Piccadilly""")),

Test("""Parsons Green""",listOf("""District""")),

Test("""Perivale""",listOf("""Central""")),

Test("""Piccadilly Circus""",listOf("""Bakerloo""","""Piccadilly""")),

Test("""Pimlico""",listOf("""Victoria""")),

Test("""Pinner""",listOf("""Metropolitan""")),

Test("""Plaistow""",listOf("""District""","""Hammersmith & City""")),

Test("""Preston Road""",listOf("""Metropolitan""")),

Test("""Putney Bridge""",listOf("""District""")),

Test("""Queen's Park""",listOf("""Bakerloo""")),

Test("""Queensbury""",listOf("""Jubilee""")),

Test("""Queensway""",listOf("""Central""")),

Test("""Ravenscourt Park""",listOf("""District""")),

Test("""Rayners Lane""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Redbridge""",listOf("""Central""")),

Test("""Regent's Park""",listOf("""Bakerloo""")),

Test("""Richmond""",listOf("""District""")),

Test("""Rickmansworth""",listOf("""Metropolitan""")),

Test("""Roding Valley""",listOf("""Central""")),

Test("""Royal Oak""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Ruislip""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Ruislip Gardens""",listOf("""Central""")),

Test("""Ruislip Manor""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Russell Square""",listOf("""Piccadilly""")),

Test("""St. James's Park""",listOf("""Circle""","""District""")),

Test("""St. John's Wood""",listOf("""Jubilee""")),

Test("""St. Paul's""",listOf("""Central""")),

Test("""Seven Sisters""",listOf("""Victoria""")),

Test("""Shepherd's Bush""",listOf("""Central""")),

Test("""Shepherd's Bush Market""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Sloane Square""",listOf("""Circle""","""District""")),

Test("""Snaresbrook""",listOf("""Central""")),

Test("""South Ealing""",listOf("""Piccadilly""")),

Test("""South Harrow""",listOf("""Piccadilly""")),

Test("""South Kensington""",listOf("""Circle""","""District""","""Piccadilly""")),

Test("""South Kenton""",listOf("""Bakerloo""")),

Test("""South Ruislip""",listOf("""Central""")),

Test("""South Wimbledon""",listOf("""Northern""")),

Test("""South Woodford""",listOf("""Central""")),

Test("""Southfields""",listOf("""District""")),

Test("""Southgate""",listOf("""Piccadilly""")),

Test("""Southwark""",listOf("""Jubilee""")),

Test("""Stamford Brook""",listOf("""District""")),

Test("""Stanmore""",listOf("""Jubilee""")),

Test("""Stepney Green""",listOf("""District""","""Hammersmith & City""")),

Test("""Stockwell""",listOf("""Northern""","""Victoria""")),

Test("""Stonebridge Park""",listOf("""Bakerloo""")),

Test("""Stratford""",listOf("""Central""","""Jubilee""")),

Test("""Sudbury Hill""",listOf("""Piccadilly""")),

Test("""Sudbury Town""",listOf("""Piccadilly""")),

Test("""Swiss Cottage""",listOf("""Jubilee""")),

Test("""Temple""",listOf("""Circle""","""District""")),

Test("""Theydon Bois""",listOf("""Central""")),

Test("""Tooting Bec""",listOf("""Northern""")),

Test("""Tooting Broadway""",listOf("""Northern""")),

Test("""Tottenham Court Road""",listOf("""Central""","""Northern""")),

Test("""Tottenham Hale""",listOf("""Victoria""")),

Test("""Totteridge & Whetstone""",listOf("""Northern""")),

Test("""Tower Hill""",listOf("""Circle""","""District""")),

Test("""Tufnell Park""",listOf("""Northern""")),

Test("""Turnham Green""",listOf("""District""","""Piccadilly""")),

Test("""Turnpike Lane""",listOf("""Piccadilly""")),

Test("""Upminster""",listOf("""District""")),

Test("""Upminster Bridge""",listOf("""District""")),

Test("""Upney""",listOf("""District""")),

Test("""Upton Park""",listOf("""District""","""Hammersmith & City""")),

Test("""Uxbridge""",listOf("""Metropolitan""","""Piccadilly""")),

Test("""Vauxhall""",listOf("""Victoria""")),

Test("""Victoria""",listOf("""Circle""","""District""","""Victoria""")),

Test("""Walthamstow Central""",listOf("""Victoria""")),

Test("""Wanstead""",listOf("""Central""")),

Test("""Warren Street""",listOf("""Northern""","""Victoria""")),

Test("""Warwick Avenue""",listOf("""Bakerloo""")),

Test("""Waterloo""",listOf("""Bakerloo""","""Jubilee""","""Northern""","""Waterloo & City""")),

Test("""Watford""",listOf("""Metropolitan""")),

Test("""Wembley Central""",listOf("""Bakerloo""")),

Test("""Wembley Park""",listOf("""Jubilee""","""Metropolitan""")),

Test("""West Acton""",listOf("""Central""")),

Test("""West Brompton""",listOf("""District""")),

Test("""West Finchley""",listOf("""Northern""")),

Test("""West Ham""",listOf("""District""","""Hammersmith & City""","""Jubilee""")),

Test("""West Hampstead""",listOf("""Jubilee""")),

Test("""West Harrow""",listOf("""Metropolitan""")),

Test("""West Kensington""",listOf("""District""")),

Test("""West Ruislip""",listOf("""Central""")),

Test("""Westbourne Park""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Westminster""",listOf("""Circle""","""District""","""Jubilee""")),

Test("""White City""",listOf("""Central""")),

Test("""Whitechapel""",listOf("""District""","""Hammersmith & City""")),

Test("""Willesden Green""",listOf("""Jubilee""")),

Test("""Willesden Junction""",listOf("""Bakerloo""")),

Test("""Wimbledon""",listOf("""District""")),

Test("""Wimbledon Park""",listOf("""District""")),

Test("""Wood Green""",listOf("""Piccadilly""")),

Test("""Wood Lane""",listOf("""Circle""","""Hammersmith & City""")),

Test("""Woodford""",listOf("""Central""")),

Test("""Woodside Park""",listOf("""Northern"""))
)

for (r in tests) {

val result = v(r.input0)

if (result != r.output) {

error("Error during $r, expected ${r.output}, got $result")

} else {

print(jotlin.runner.TestUtils.tick)

}
}
 

Это решение изначально имело такое же количество байт, как и станции. Полагаю, можно было бы сократить еще примерно на 50 байт, но мне показалось, что на этом месте лучше остановиться.


Введение

Mathematica хорошо известна своей большой стандартной библиотекой и доступом к большой онлайновой «вычислимой базе знаний». Я нагло поискал в Wolfram|Alpha, надеясь легко найти нужные данные о транзите, но хотя он понимает предметную область моего запроса, данные пока недоступны.

К счастью, обширная встроенная документация Mathematica содержит изящные примеры. Некоторые из этих страниц просто случайно использовал сеть лондонского метрополитена, чтобы продемонстрировать функциональность, связанную с графами. Мы будем использовать график из Пример «Планирования поездки» из-за его короткого названия.

Вот другие интересные варианты использования той же сети.

Я не считаю, что программный доступ к собственной документации Mathematica попадает в задачу «Извлечение из внешнего источника»- типа лазейки.


Импортируйте пример страницы

Мы можем импортировать страницу примера как выражение блокнота:

{x->d("eJw1VcluG0cU/BWfchoC/dbuPpJDkTM2EuSUnGmFgIlQYkAzBwNEvj1VrUSHkXp7S1W90v7y/XG/vD6ev15eX09/XK7XH8/5cn+9np8/nx/321+36+Vxen8up7e38/372+Xx7dNPn+bL48fzl9v98e18f3/uTn+e79fb7fn576+X6/n8nM/vj/vp+vz99BgH/7/4DYlu98vpH83i290k0vq8nzbqptuXSa3GDiurbT+JRztMKpUf0R1OJXdTtnKcX5b9pKXgpOZ6+Dxtsuf8sp/MEGWjEm3FURSmcI15O0npvmWiKofJsyx447FyR43nKvYFqyzrMmkIUieTilZHSWHOyJKdz0vFVamNJUvKih0/YKfpKN9RsnRfpm4LWqyJb6uKLBuxjtXGiqJr6YFobLeujOfliGV0Nh8dYcOCb9KEGJnmYWoNmTIISiorE5eRuzZlLLWOTQu8qK1tJ9XM8dUVNfWO5sR0JRQ1ScFGo/Xx24yoZesMJzH6tdJ5Nb3vmas3Y+Iex5nHJhUVS5XKMqtxG2svhYGA9Bdk64XMqBQj2qU3LpGtoJtNV1u4Kt53hL8lam7BYpsDMfInLEhrj/ll6sR/g1gMJmo+gkk6MloujBHRtuNKR5AUFIogNYLvPJP3ypF9xnEyD5TW2Jo0cCcZMr5g3itwlRIDDlNH6E5irTmYbN2JiIesu6lmjHLaiORVWQDYJRNDPlpMRpIsu8FVw2M0CzAhvyOCCrkikRresZFppM0r1SK8gl4Wihow7A9oFKSw4t6IC6lJPiuoRD1y7GUtB+ZTUc6DDL1H2PpBAdS8sDkOEdVbEQGBMjhrBcihgHGk0OSRnPW2Dllo16E5Slobs+3JezWSAaaGqttoRyG5WsiFilMWSUCMSsTwB+uI6ojuzZCX1eGgyKC10wZq3ZOusv43QOwoGoYfMs/BLX2ilX5cqTetQ5xaGm6COIyQVMU0SSnliBQlOelmZT+1xE1Ahz+lqw/dBFsVVaC9aYbJNAcV8B7yjWahNMekkmgYDLzEhoFRgVI+yMCoDoITvaDTMTphOoSgA7ToIFbHSAh1j9nhn70630MCtKTGMbACOsKSegHQW2KUkG7PD9OoAFuUVTXHGGoRtJ0C9/EmCAKVLBxJGc7opWMooS5QbfCBhUmdkIK84V3FuYffo8wykmTHEGAg+XX43fC6RhNshUY5WrIwXhJBiSbUuduwXKuUcqdHELHhGzEw8cBUpbR5SwxKxSqcTCEUHVYDwvemx4UeH07TtKFSaEZgHKjTqCmFx/U6DLAq/gcs7EQaZ4cKElpgaUPk1ohw7Rhi3sIPB8Y6hTBgA7Ve6buBVgBSxXyH4RHm1RkCW4d/AeEEm1Q=").split("~").w{v ->Regex("(-?[0-9]+)([A-Z]+)").findAll(v[1]).f{x.hashCode()%2897==b.groupValues[1].toInt()}.m{b.groupValues[2].m{v[0].split("|")[b-'A']}}.first()}}
n=i=0 for e in(input()+' '*26)[:26]:n=n*256+ord(e) w=bin(n)[2:] for j in'Bakerloo,Central,Circle,District,Hammersmith & City,Jubilee,Metropolitan,Northern,Piccadilly,Victoria,Waterloo & City'.split(','): for z,o in eval('eJxNVclxAzEMa4gPHdRVi8f9txEApOQ8MhNrtSQAgtjP5/Op3fq0cWw3O8dqbV/7TLfVbO8v/v/UZq3ZWrbdTsEJ7k+PR3jZbU471WpZeHvguLZyn9ZtbVpb7w7fr25joUFcOtaOebOx8ZhXHMej23gt0B2/J8/7V4dqvKxvmzVQT6udFxzYju6gbbG1o5+jZbIpxpbVvJNyLQenq9gu+RYu9IIiqCsuLNO7+bbVdQVscAGNTqdUkGZEZSdXMEFl9cUP/0EZ1UYDC3YCTr9oSIJykzWg6XioUqcmGyK2GSzYFtBGitApLMXDxaK7w47H1day0CCSTgGTIeF7wtwsTH5v0n3YXHb4EmrmmHsOEe/RK5tXFnoR8xuSHtNHnUapnSwhM6Wrt9DxS6bfylIKXTkhzA4qr0vPOWMyOxzHTsEHFfMA3GbYBn+NxOfATB/LRZZS+x9FcYlZQK54VSqswCl5hYxjpIO4B3iO2T1Ne0Jp18WEWDVymksOGi3rEG4Tj5r8VM1jHHyEzQOMMHjnFqQCmO0I7y8ZUgY3wJ/xKv7FGKC2ELJnumoSXf1NLxasSsPKLeXGRDeQxjLOcplgJbTv0IOOkqq5znoFvicVRMG8groALmftMwPJ2ncMbecAL3GWS/+iGCUGnFY02hH+hxnW0AEclIsLEtzLTRLiu8o9X6TFvuv1nXeJNdtjcljIMeQMDVeKDo1KiMAB9qVE8oTa03rlrgdlJJlgAmqpDVXpAtdieUDALxKwSaLzmm1bfw7gD9yQrYbIRAjDSWlz7nPleiyZOTTqsfIz1jAn6T91YyEx2LkiElAPVrwpwGiukhQ9q1O+X8R1OiLC7TSltkyuQELiYto7gt4YxP0G+ZiRelnEiS4+CVOJO/6FOgNI2wvNl8SuP2CYEVdUejDhuRRK8nPJTSVVfXmH2oSfHi4ZiG9W+67jYIJxaUaOYd3ATTyRRuOXIjGaFnPxcHdOLhQFChoQctYSEdBfPvFrcnaiR535vqr6JlDnmt8gD5/9kt31WZ47I6w9rE1T3fk1Zcaul01dqSb/NIFLINVif7Q5ir/bauccZuwCv93f7x8/H97i'.decode('base64').decode('zip'))[i]: if all([w[k]<'1'for k in z]+[w[k]>'0'for k in o]):print j i+=1

Можно извлечь весь график из глубины выражения блокнота:

eval(gzinflate(base64_decode()))
[]

Обратите внимание, что вершины графа — это просто названия станций. Края имеют индивидуальный дизайн array() property that is a list of strings representing the lines that pass between its two stations:

H
Piccadilly

Теперь мы могли бы найти все прямые, проходящие через вершину, взяв все инцидентные ей ребра из ddb , mapping Piccadilly над ними и так далее.

Однако мы пропустим описанный выше метод и сэкономим много байтов путем сопоставления с образцом для соответствующей части District constructor – the Acton Town вариант.

Извлеките строки

8 constructor has the following format:

3

(Вы можете убедиться в этом, проверив fe5 or reading the source code of fe538 – чтобы узнать полный путь, запустите Heathrow Terminals 1, 2, 3 .)

Вот пример одного свойства края:

Dagenham Heathway

Давайте превратим это выражение в компактный шаблон:

Heathrow Terminals 1, 2, 3

Сделать справочную таблицу

Теперь мы можем сопоставить ddb , eval(' // base64_decode(gzinflate()) long string into the further beautified: function a($b){ $c="fe538,e0526,cb734,cd88,3156,0447,f267,b198,a498,22c02456,95b7,54317A,a5e246,6ee34,9061,17938,03323,2963,2ad7,de35,0101,5b423,cad9,d2415,1eb7,ee38,bdc8,f8334,7907,ec79,85034,26e1,6a87,9ca8,8747,1715,4875,acf5,5f023,6245,9596,81e7,ae91,78e07,8ab6,7cf1,c473,a2e6,cea7,b407,ee57,0748,16f7,a5d7,4028,fa26,f723,ddb3,a8c1,9035,7c513,36a38,07838,0a31,9b57,70d34,5c03,4d068,7d87,6130234,85507,adc3,68e0237,1ac1,f0079,6af246,8871,6fc246,4fe7,ad456,8e389,f743,a431,24d238,bad7,3f324,8e57,f901,793246,0641,a6a589,dd23,3541,0202348,4127,cb51,a070,38e0,0976,24b8,7918,7de8,5a07,6d17,2729,3197,89823,af268,9ff18,bce1,9bb8,0523,5468,9a78,67a8,3928,0ff68,83e7,c100,6713,9717,0ab0,fc53,3415,8a10,74c5,b0e246789,0288,16a24,cf60,bf71,66424,73778,ed21,2ff1,0e01246,dba57,f5b1,b500,c318,40923,ae71,7720,19e134,0d37,6a723,3662467,5e76,5f57,f997,4735,dab1,3451,c778,ef75,2ed6,7960,b038,1631,40a6,52b6,ae26,2e9123,ffe8,de27,3678,55d7,45a019,0cb0234,8f98,0893,6a21,10608,c349,98b6,1d734,a726,05d3,fae0,70c5,1991,6ef3,8f168,8771,f790,cc83,76e6,e241,8ec24,31168,7b61,6e268,26f8,7bc23,7a75,e6a1,f4b9,8661,6e724,cc023,ef11,1878,fe78,116238,d060,6081,9f07,9f21,de83,7c48,c295,7c33,d5d5,26334,42c79,e4f0,f3a15,7b58,bbf8,24f5,10423,c0c1,68b7,2aa7,c7c17,8349,a567,36d23,dcb7,b0d38,0bd8,2cf3,bef3,6123,b6b34,18468,c1b9,c51239,38e9,d881,b5579,a4c0,ccc057A,a8d6,a870,e0856,df31,ed43,f277,287345,55e5,b476,bb93,8931,f2424,49d235,70b1,45634,f0e5,7f80,62b3,7ca3,0f18,a8624,6361,3847"; $d=["Bakerloo","Central","Circle","District","Hammersmith & City","Jubilee","Metropolitan","Northern","Piccadilly","Victoria","Waterloo & City"]; $e=substr(md5($b), 21, 3); if($e=="ddb" && $b[0] == "H") // hard-coded Heathrow Terminals 1, 2, 3 here return $d[8]; foreach(explode(",", $c) as $f) if(substr($f, 0, 3) == $e) foreach(str_split(substr($f, 3)) as $g) echo $d[hexdec($g)]."\n"; } '); , и eval(gzinflate(base64_decode('TZXLimRFEIZfZSiKoQsCyfuFpjfqQgTFlS7GQfJqF/Z0DdU1MCK+u1+0DrgpzjmZEfnfImt/eh638+X5Tbs79tNfx/Fw2Cv6IstEl2T07IOMWYp4G5OYELJsl7J0W4u0wI9zw7jAYo09Swze5iYtLheSpLWoryZZsbnS1njvvLia+Gkzy1w+irHGSuyBldFmlemCjWIX7agv0ucosounVa6GjyNXKdHw7tKyklrJUkcrUjL4bKY6lByljR0lbkPjBEQQ1iTFrixtVSu5LLqV1pPksa2MkL00t+C9GhSDnrViFpNDEZs2dRHQwTjwNPTZmdZzdsrKsBCFTR7RevGpKd1c9Ld51jqNspmAjsN4CdOkInkCPVkPxAClyIltDuACzXm4NNpuYyCc2lZJS8kw3kOfw1YqU8UvCFXBE4CCBeLCdCqdiuy3d3RXJrsiNU5otUnBSkstUjjZLT7ywTjFUiRYl/E/ssVkIx5AYmpOdO7grlbBryKRZUnTZnHZVWJSkbQW2oEXhnVvtvaxVAIqyZUnJbrScpGUsc1XBDV787F4KA1rDCvIWDONTetG9ogg1GCUZo3kMKJ0oynL4McRdajBc+xkpG9VKQXes8+cs6ZDFLCIWcYq/dmbChK7lR45b3hwBlMV+aI6Z2fE1mVxBtsg2dRtn5KeKXGhRdyvmkKZ6ESZjWY+oNl4PXOTQbcm8aqKyXjFiDnBNGoduWuLFDnCSOe9kXMuZPdwkvgaNeS10Bv934RsBs6USkAafKxJpgA8VKmFbnbquAITc+OkY8O0bFDKVvKe1va0sCpzhuFmmmSM4iUnQo+WlpSQLFzUTbknLVIXXdr6PoCZG6xWatSHzhym101ZlR86aWtbkBUYkE4I26RBJO1Yagop2ASmbuATH9oNwjZc1cHxDFOcaJZ01oPTOV9hY75vGJ97JEkdJC4w2Na83hiGCUmFu8I1hnbkQWKKStJiUik12ZOLDP2nDmOf1A+U6CpHUuV76pxni6ZyWEgxws5XDT2jUYomJIKlhaGCDRP1iisYy81juCsLEzg3zq7JAG6XQVPwgtsnLnIayErv2IZ16OY0l6GCDFKGzDDBANiGvXkXhHJdlWmeqSCVrZA5SR6lfQn5cH+cD+8OX7c/1vXpcjnI4Zv1fLu2J306X8fT4uHb88vteh43Hr9rHz6s68uH8+3xzds335xvf/Lx+0/9/LR05w/rdr18vDydb+2Z1x8v19vjuurjT+fBhXx+etKCn2l2uZ4bj7+02+vJX7q9vz+uh5dPnRPvPsyofyWCv/50f953LD0cuCMPb98e+zvznrfvDqfrun26Ph/nu/L+fl+uq43Hu/X549NlrjtOkOM4tZfjPtHgv8bHLVxDp4eH4zp9qeD7by8fQf6/Tf6klb+f1ni80P9xfZ5r3PHh/VeHX58P93//Aw=='))); , but we want 0000000: 6c95 594d 77db 3a0e fd2b 5ab9 33e7 3873 l.YMw.:..+Z.3.8s 0000010: ce7c ccaa ab3a 6d93 d797 be66 92bc 7a0d .|...:m....f..z. 0000020: 4b88 c563 8af4 8054 1ccd af1f 1066 484a K..c...T.....fHJ 0000030: 4aec 7417 5f80 e025 085c 92ca a7da 5b53 J.t._..%.\....[S 0000040: 3dd8 8359 7c56 ce93 aafd f256 d535 344a =..Y|V.....V.54J 0000050: ebe1 e327 dd6c c1e3 e252 51ad 71f9 1d3d ...'.l...RQ.q..= 0000060: d9bd d5ca 8379 b155 5fc0 f93c f81a ba0e .....y.U_..<.... 0000070: c975 cab7 1598 a6ba 543e 84d9 23f1 448b .u......T>..#.D. 0000080: 3274 706b a15b 8c83 9a2d eac5 1f96 7c8b 2tpk.[...-....|. 0000090: c43f a96e 0f30 9480 b1ae ba22 fb84 a360 .?.n.0....."...` 00000a0: e4d0 802e a115 ec90 aa7b 4f88 7e21 3fb4 .........{O.~!?. 00000b0: b5cb b890 d758 2ebf f51b a571 b2ca 1568 .....X.....q...h 00000c0: 2699 09ac c0ec 1697 683c 815e bea0 cb35 &.......h<.^...5 00000d0: 7889 9f82 b11f 6d54 0d66 7162 c6e9 4cb4 x.....mT.fqb..L. 00000e0: 5366 7b26 95d1 cba9 065f 6804 cc1a 575d Sf{&....._h...W] 00000f0: da9e 8a9d 18e5 6270 8740 f185 cd8b d3c7 ......bp.@...... 0000100: 15d6 d684 1c2d 0a48 3bf5 3fac 6e79 a662 .....-.H;.?.ny.b 0000110: dd48 9d35 8dc3 6111 f3c4 906f 0d68 de0d .H.5..a....o.h.. 0000120: 4493 c968 a877 8fa4 80dc 6c36 b1b5 961c D..h.w....l6.... 0000130: 5677 169a c54f 062d bb7e 5c71 e8b8 5729 Vw...O.-.~\q..W) 0000140: b969 1a4b b6df b605 15eb 42d1 7e07 6369 .i.K......B.~.ci 0000150: b4e3 b667 8291 ce08 3fc8 74e7 324b 3c71 ...g....?.t.2K<q 0000160: 7549 d6b9 622e 52cf 3c59 c194 6ca7 71b8 uI..b.R.<Y..l.q. 0000170: d80c 171c f75c c89e 97db 93f3 d535 33c9 .....\.......53. 0000180: 29ea 8967 fa01 457a 2f41 6363 8d02 2354 )..g..Ez/Acc..#T 0000190: 0bfa 6cea 1a8c 3d5a f81b 68a0 92ba 4b1b ..l...=Z..h...K. 00001a0: 1240 1aaa 750b f458 8286 0b46 c68f 406b [email protected]..@k 00001b0: 52c6 27db c456 6b9c 1440 1ed1 827e b44c R.'..Vk..@...~.L 00001c0: 7b51 dd80 57bc d651 e38a 7d57 7d05 4abd {Q..W..Q..}W}.J. 00001d0: 2298 a991 061e 6172 b532 4a81 9064 3a77 ".....ar.2J..d:w 00001e0: 6631 0a67 bac0 a0da 1eb0 c821 03ee a0ea f1.g.......!.... 00001f0: dd91 65a6 de5a d238 1cac 6d26 0134 ec39 ..e..Z.8..m&.4.9 0000200: 2a37 49d7 d994 c88c 0b30 87ef 6d3f 822d *7I......0..m?.- 0000210: d7b6 751e c98d b688 2731 0d68 2c3d b556 ..u.....'1.h,=.V 0000220: ec56 ad99 4a09 3f85 2abb 026a c645 cad9 .V..J.?.*..j.E.. 0000230: 7866 e263 d29f 618b 8669 8c35 36c3 d708 xf.c..a..i.56... 0000240: 5ef4 319b 70d3 14cd f839 b070 527d 6927 ^.1.p....9.pR}i' 0000250: bf80 0ee9 e742 8626 8c8d be79 fba3 43cc .....B.&...y..C. 0000260: d42b 7ac2 1ea4 3f9c 129c c0b7 92b3 2551 .+z...?.......%Q 0000270: 11e8 ab32 75ab b110 7481 b979 ce74 92b8 ...2u...t..y.t.. 0000280: ddf6 de60 5eac 80b5 f538 4ada 8846 b33d ...`^....8J..F.= 0000290: 0015 bb12 01e9 b1d9 a170 8681 46ae 0869 .........p..F..i 00002a0: 804b 9e57 e3bc 74d9 a79b d4e3 976e 0366 .K.W..t......n.f 00002b0: d7a1 f16f 4f97 87ef f79c f89c b1de f9a2 ...oO........... 00002c0: 5497 4983 c4c0 ddfb df1e 08df 7fc0 7c05 T.I...........|. 00002d0: c5f3 ef53 7c6e d6d0 888d 35bf 1023 6e60 ...S|n....5..#n` 00002e0: 1583 2476 d922 b98d c536 1bec 363d 0d92 ..$v."...6..6=.. 00002f0: a3a2 f8f3 cabe f6e1 b4cd b599 f278 05c6 .............x.. 0000300: bbb1 8a5e 69db d718 7a51 a6cc 2a36 2fc7 ...^i...zQ..*6/. 0000310: 2bab 1ba4 7834 24ca 02b7 70d8 c9f8 5339 +...x4$...p...S9 0000320: 604f db6c 31ea 6511 80c0 303c a645 085c `O.l1.e...0<.E.\ 0000330: aaec a221 1f6a ef4e b050 7cb4 d494 01d1 ...!.j.N.P|..... 0000340: 8cc4 78f9 5aea ae7a 6390 24bf 396d d7a0 ..x.Z..zc.$.9m.. 0000350: 0cf4 daa7 6005 81c5 7bca becc 22db f7ce ....`...{..."... 0000360: 2314 7276 1dd6 4f23 7d67 8c34 ba06 4daa #.rv..O#}g.4..M. 0000370: f800 913d 70e7 ac11 7413 8a17 a7c6 0b6b ...=p...t......k 0000380: 2e38 e685 e4b2 cc08 db3d 0f88 c745 4147 .8.......=...EAG 0000390: c42f 847d 40ea 9401 edaa bf2f ab7f 2cab ./.}@....../..,. 00003a0: 7f9e f4aa fe75 dafc efb1 d934 d6cc 8bfd .....u.....4.... 00003b0: 5a6d db6a 0564 d08f 4129 ef45 f59b 0b12 Zm.j.d..A).E.... 00003c0: 5a5e 1cc4 2a77 e991 7fac 8fea 7734 2e8e Z^..*w......w4.. 00003d0: 989e c621 23b1 4ddf d2b9 6bab 3796 92d6 ...!#.M...k.7... 00003e0: 4e4c 5287 523f d12e a03d 40ec d591 3771 [email protected] 00003f0: 17f7 54b7 450d d9de 3876 4f59 c8fe d916 ..T.E...8vOY.... 0000400: a4f8 55c3 1a27 86a1 4121 c3a7 0719 a4d2 ..U..'..A!...... 0000410: f65b bd93 73ed cd75 7296 4ccc 52ca 2263 .[..s..ur.L.R."c 0000420: 2e5d 4253 51e5 7c56 7ff9 a187 6eaf e0af .]BSQ.|V....n... 0000430: 7949 6cf5 cab5 e33b 95a0 7614 e310 0f6a yIl....;..v....j 0000440: 570c 559a f738 dfa4 e26f 5952 3194 e796 W.U..8...oYR1... 0000450: 56cc 7e8c 7c70 c72a e64d ff1b 0f30 3581 V.~.|p.*.M...05. 0000460: 7bb7 32a4 63e2 d5ee ffdd 7031 79b7 21c5 {.2.c.....p1y.!. 0000470: 3a55 e6f4 069a 0dd9 1dc6 37d3 89d9 d8b5 :U........7..... 0000480: db20 0332 515a 0bc3 a606 91d9 2bf0 b9cd . .2QZ......+... 0000490: e32d f0bc 76de a08a 321d 0fac f942 82d3 .-..v...2....B.. 00004a0: 505c 16e2 4f11 8a8c a927 a4bd b57a fa50 P\..O....'...z.P 00004b0: 78b7 b6de 58e9 e695 2429 8969 daff 9bf0 x...X...$).i.... 00004c0: cc28 597c 07d5 40f5 1374 a156 f2ea a8b8 .(Y|[email protected].... 00004d0: bc5d 99e6 003b 654d 344c 5a98 adb4 d158 .]...;eM4LZ....X 00004e0: 85d7 6c11 9c06 8d1b 6bca e08a bdbe 98a4 ..l.....k....... 00004f0: fda7 b539 b86b 397c a4fd 7221 7fb7 a697 ...9.k9|..r!.... 0000500: 2bc7 8c87 b524 1af4 cb45 2743 8f45 5eda +....$...E'C.E^. 0000510: 1996 8b6c e146 d2a1 22d8 e86a 3405 af3f ...l.F.."..j4..? 0000520: 105c 83a9 77f8 f741 f472 a44d e25d dc1d .\..w..A.r.M.].. 0000530: 3376 bc97 1659 8fb8 b4fe 41d5 6d0e 2cf8 3v...Y....A.m.,. 0000540: f160 19f1 8d96 3576 bc1f 434e bcc0 8f0a .`....5v..CN.... 0000550: 75e3 66f1 adf6 6322 f9d9 310f 3d7b 7864 u.f...c"..1.={xd 0000560: 5876 ca4d 8dde f39a c434 6aaf e574 ebf8 Xv.M.....4j..t.. 0000570: b528 b10b 763f 7433 bb91 fc08 8d16 9656 .(..v?t3.......V 0000580: fa3d 812e 3c9e c3ed a20a f1fb e2f9 15e7 .=..<........... 0000590: cd8a 720b 4d13 b5f6 d72e ca22 ee77 7628 ..r.M......".wv( 00005a0: 4f0a 419d 35f1 0a96 e5f4 1649 31bd dce5 O.A.5......I1... 00005b0: 79c8 8c62 194d 755a d576 91d9 2a63 a64f y..b.MuZ.v..*c.O 00005c0: d25b 0d3c cdd9 47fa 2d21 7bc5 77f7 3880 .[.<..G.-!{.w.8. 00005d0: bc37 a25e 64ce ffe9 11cd 0737 917c 4147 .7.^d......7.|AG 00005e0: 9a1f a1e2 8df5 f10e 9e18 a9c3 bb69 fc50 .............i.P 00005f0: 60cb 6098 9a5c a5de 3cff eeb0 890a 9f02 `.`..\..<....... 0000600: e216 8d9f 91b9 e36e e8ac 698a f85c b41d .......n..i..\.. 0000610: 301b 11f7 d132 ef6c d8e8 a073 1a33 55d9 0....2.l...s.3U. 0000620: 41f9 4871 4adc ef7a e5b4 dabf c138 d9d3 A.HqJ..z.....8.. 0000630: 399a a247 5ce4 f4c4 68e7 50eb 9783 a3b0 9..G\...h.P..... 0000640: 8413 f41b 74e8 e2d2 6752 270e b6e5 7d92 ....t...gR'...}. 0000650: 1778 da93 e3d1 dbeb 0f99 cb3d f2a6 54f7 .x.........=..T. 0000660: 4a9e f5b9 a4ee 5bdc b748 0d47 58f5 2e0b J.....[..H.GX... 0000670: f704 e725 d0ee e40d 9fd9 6a0b 06e3 32e6 ...%......j...2. 0000680: 540d a36e 43d6 eef2 24b6 7f55 f118 cfca T..nC...$..U.... 0000690: 36c5 4fdc 2297 aff9 96bd 1dd1 b82f 131e 6.O."......../.. 00006a0: 6b15 f4b2 29af 5d62 90d4 0639 29fd 9390 k...).]b...9)... 00006b0: a605 0a28 e7ce 94c5 8173 576c 0d74 a24d ...(.....sWl.t.M 00006c0: 2b49 45b1 9560 3a4b 5838 e2de e030 d192 +IE..`:KX8...0.. 00006d0: 3752 ef6d bd93 2f47 f377 34db 0c1e 1b6a 7R.m../G.w4....j 00006e0: dc3f 6c21 f0e5 c296 69ee be09 3d2e 8a5d .?l!....i...=..] 00006f0: 2c27 e172 a52c f183 72e1 4b89 f7b0 cd2b ,'.r.,..r.K....+ 0000700: 78c0 6eaf e795 f0d0 e220 3714 ab72 793e x.n...... 7..ry> 0000710: 582b 67c4 0aeb 9cfe 08e6 9772 61f1 5e6e X+g........ra.^n 0000720: d1c7 cf33 226b 6915 af78 5d83 c65c f482 ...3"ki..x]..\.. 0000730: 4b46 c26b ad45 2f77 b032 fa01 4916 3f27 KF.k.E/w.2..I.?' 0000740: df3f 1ad4 7afc dd98 5192 6926 7b95 3324 .?..z...Q.i&{.3$ 0000750: 1e7b b5c3 a3f4 1586 3ff7 9d32 a129 d3b0 .{......?..2.).. 0000760: 0c65 514e 1683 43f9 9379 0b95 33f5 f1e7 .eQN..C..y..3... 0000770: b314 c0db 9afb 13fa e716 b4ce 397a f963 ............9z.c 0000780: d663 c963 0dda f3a2 9d2f 5e4d 8531 ac20 .c.c...../^M.1. 0000790: 6f0a 0344 68a6 4779 198d e4ca f189 65aa o..Dh.Gy......e. 00007a0: 2f6e 8b2f ff74 48c8 4b91 9efa bfc4 5aea /n./.tH.K.....Z. 00007b0: 7a72 d0c5 fb50 e29a a788 86d1 d787 c9d0 zr...P.......... 00007c0: d997 3e81 b830 3bde 83bc e502 cf3f 000a ..>..0;......?.. 00007d0: 7cfe 0360 ea3f 71cf 5f22 c6f0 fcc2 2786 |..`.?q._"....'. 00007e0: ac8b 533a 13b9 1370 637b 3251 104e 88ba ..S:...pc{2Q.N.. 00007f0: f8c6 6a9c 5642 66db 2a8f e29e a610 a86e ..j.VBf.*......n 0000800: 618f fa4c 69ae 953e 7e48 89cd 9382 26fc a..Li..>~H....&. 0000810: 5b6f 6aaf 4a15 4f4a 9d62 6768 72e3 08da [oj.J.OJ.bghr... 0000820: 3dff 6789 a0d2 8927 d73e d17d 019c 6a70 =.g....'.>.}..jp 0000830: d2fd ff07 .... . Полезно, lambda I,p="Woods|Woodf|Wood L|Wo|Wimbledon |Wim|Willesden J|Wi|Whitec|Wh|Westm|Westb|West R|West K|West Har|West Hamp|West H|West F|West B|Wes|Wembley P|We|Watf|Wat|Warw|War|Wan|W|Vi|V|Ux|Upt|Upn|Upminster |U|Turnp|Tur|Tu|Tow|Totter|Tottenham H|Tot|Tooting Br|To|Th|T|Sw|Sudbury T|Su|Str|Ston|Sto|Ste|Stan|Sta|St. P|St. Jo|St|Southw|Southg|Southf|South Wo|South W|South R|South Kent|South K|South H|So|Sn|Sl|Shepherd's Bush |Sh|S|Rus|Ruislip M|Ruislip |Ru|Roy|Ro|Rick|Ri|Reg|Re|Ray|R|Queensw|Queens|Q|Pu|Pr|Pl|Pin|Pim|Pi|Pe|Pars|Par|P|Ox|Ov|Os|Ol|O|Not|Northwood |Northwo|Northw|Northo|Northf|North W|North H|North G|North E|No|New|N|Morn|Mor|Moorg|Moo|Mo|Mill|Mi|Mary|Mar|Mans|Man|M|Lou|Lo|Li|Leytons|Ley|Le|Lat|Lan|Lam|L|Kn|Kings|Kin|Kilburn |Ki|Kew|Kento|Kent|Kensi|Kens|K|I|Hy|Hounslow W|Hounslow E|Hou|Hor|Hollo|Holl|Ho|Hil|Highg|Highb|High S|Hi|Hen|Heathrow Terminals|Heathrow Terminal 5|He|Hat|Harrow-|Harr|Har|Han|Hamp|Ham|H|Gu|Greenf|Gree|Gre|Gr|Goo|Goldh|Go|Gl|G|Fu|Fins|Finchley R|Fi|Far|F|Euston |Eu|Ep|Em|Elm|El|Edgware |Ed|Eastc|East P|East H|East F|Eas|Ear|Ealing C|E|Do|De|Dagenham H|D|Cr|Cov|Coll|Col|Co|Clapham S|Clapham N|Cl|Cho|Chis|Chi|Che|Char|Chan|Chalk|Ch|Cano|Canno|Cann|Canar|Can|Cam|C|Bur|Bu|Bro|Bri|Br|Bow|Bou|Bos|Bor|Bo|Blackh|Bl|Bet|Ber|Bel|Be|Bay|Baro|Barkings|Bark|Bar|Ban|Bal|B|Ars|Arn|Ar|An|Am|Alp|Aldgate |Al|".split('|'):[j for i,j in enumerate('District|Piccadilly|Northern|Central|Circle|Metropolitan|Hammersmith & City|Jubilee|Bakerloo|Victoria|Waterloo & City'.split('|'))if[int(x,35)for x in'4 8 2A 2 1 1 7B 3N 1U 8 45 2A 8 1 W 3N 5I 4 1 8 4K 7B W 15C 7B EQ 8 EM F4 EM Y 1U 1 1 1 2 3 4 H 4 EM C 4 4 8 H 3N 2 2 3V 7B EQ 1U 3N 1 8 3N H 3N 2 1 8 4 8 7B J 2 2 8 H 2A 8 EM 2 Y 8 Y 2A 8 W 1 7B 8 Y 1 8 3N 7B 1 W 1U W EM 7D 8 1 2 9M M6 4 2 4 2 P W W W 8 2 7B W 3N 2 8 8 3N 4 4 3B W H 4 23 7B 8 H 2 7B 8 3R 3F 8 8 6 2A 8 7B 2A 2 3N I0 7B 3N 1 7B 4 1 7B 4 Y 2 2 2 2 1 2 8 A Y 4 EM H 4 4 2 2 2 2 W 7B 7B 8 4 2D 8 1 8 IC 37 8 4 2A 4 J 8 1 EO 4K 4 37 8 37 EQ 8 7W 1 7F 9M 4 Y 1 1U 4 8 3 3 9 3N 8 1 1 W 2 4 4 2 4 4 4 W 1 8 W 7F 8 4 W 3N H 3N 3N 3N 4 2 4 8 1U EM 4 1U 2 2 4 3V EM H 8 3N 4 1 H 3 8 1U 37 TL 4 E6 2 2 4 4 W 2 1U 1D 3'.split()][p.index([x for x in p if I.find(x)==0][0])]&2**i] может одновременно сопоставлять шаблон и трансформировать его.

var v:(String)->List<String> = {x->val r=java.util.Base64.getDecoder().decode("eJw1VcluG0cU/BWfchoC/dbuPpJDkTM2EuSUnGmFgIlQYkAzBwNEvj1VrUSHkXp7S1W90v7y/XG/vD6ev15eX09/XK7XH8/5cn+9np8/nx/321+36+Vxen8up7e38/372+Xx7dNPn+bL48fzl9v98e18f3/uTn+e79fb7fn576+X6/n8nM/vj/vp+vz99BgH/7/4DYlu98vpH83i290k0vq8nzbqptuXSa3GDiurbT+JRztMKpUf0R1OJXdTtnKcX5b9pKXgpOZ6+Dxtsuf8sp/MEGWjEm3FURSmcI15O0npvmWiKofJsyx447FyR43nKvYFqyzrMmkIUieTilZHSWHOyJKdz0vFVamNJUvKih0/YKfpKN9RsnRfpm4LWqyJb6uKLBuxjtXGiqJr6YFobLeujOfliGV0Nh8dYcOCb9KEGJnmYWoNmTIISiorE5eRuzZlLLWOTQu8qK1tJ9XM8dUVNfWO5sR0JRQ1ScFGo/Xx24yoZesMJzH6tdJ5Nb3vmas3Y+Iex5nHJhUVS5XKMqtxG2svhYGA9Bdk64XMqBQj2qU3LpGtoJtNV1u4Kt53hL8lam7BYpsDMfInLEhrj/ll6sR/g1gMJmo+gkk6MloujBHRtuNKR5AUFIogNYLvPJP3ypF9xnEyD5TW2Jo0cCcZMr5g3itwlRIDDlNH6E5irTmYbN2JiIesu6lmjHLaiORVWQDYJRNDPlpMRpIsu8FVw2M0CzAhvyOCCrkikRresZFppM0r1SK8gl4Wihow7A9oFKSw4t6IC6lJPiuoRD1y7GUtB+ZTUc6DDL1H2PpBAdS8sDkOEdVbEQGBMjhrBcihgHGk0OSRnPW2Dllo16E5Slobs+3JezWSAaaGqttoRyG5WsiFilMWSUCMSsTwB+uI6ojuzZCX1eGgyKC10wZq3ZOusv43QOwoGoYfMs/BLX2ilX5cqTetQ5xaGm6COIyQVMU0SSnliBQlOelmZT+1xE1Ahz+lqw/dBFsVVaC9aYbJNAcV8B7yjWahNMekkmgYDLzEhoFRgVI+yMCoDoITvaDTMTphOoSgA7ToIFbHSAh1j9nhn70630MCtKTGMbACOsKSegHQW2KUkG7PD9OoAFuUVTXHGGoRtJ0C9/EmCAKVLBxJGc7opWMooS5QbfCBhUmdkIK84V3FuYffo8wykmTHEGAg+XX43fC6RhNshUY5WrIwXhJBiSbUuduwXKuUcqdHELHhGzEw8cBUpbR5SwxKxSqcTCEUHVYDwvemx4UeH07TtKFSaEZgHKjTqCmFx/U6DLAq/gcs7EQaZ4cKElpgaUPk1ohw7Rhi3sIPB8Y6hTBgA7Ve6buBVgBSxXyH4RHm1RkCW4d/AeEEm1Q=") var I=java.util.zip.Inflater() I.setInput(r) I.finished() var o=ByteArray(1846) I.inflate(o) var v=String(o).split("~") Regex("(-?[0-9]+)([A-Z]+)").findAll(v[1]).filter{x.hashCode()%2897==it.groupValues[1].toInt()}.map{it.groupValues[2].map{v[0].split("|")[it-'A']}}.first()} data class TestData(val name: String, val lines: List<String>) fun main(args: Array<String>) { var items = listOf( TestData("Acton Town", listOf("District", "Piccadilly")), TestData("Aldgate", listOf("Circle", "Metropolitan")), TestData("Aldgate East", listOf("District", "Hammersmith & City")), TestData("Alperton", listOf("Piccadilly")), TestData("Amersham", listOf("Metropolitan")), TestData("Angel", listOf("Northern")), TestData("Archway", listOf("Northern")), TestData("Arnos Grove", listOf("Piccadilly")), TestData("Arsenal", listOf("Piccadilly")), TestData("Baker Street", listOf("Bakerloo", "Circle", "Hammersmith & City", "Jubilee", "Metropolitan")), TestData("Balham", listOf("Northern")), TestData("Bank", listOf("Central", "Northern", "Waterloo & City")), TestData("Barbican", listOf("Circle", "Hammersmith & City", "Metropolitan")), TestData("Barking", listOf("District", "Hammersmith & City")), TestData("Barkingside", listOf("Central")), TestData("Barons Court", listOf("District", "Piccadilly")), TestData("Bayswater", listOf("Circle", "District")), TestData("Becontree", listOf("District")), TestData("Belsize Park", listOf("Northern")), TestData("Bermondsey", listOf("Jubilee")), TestData("Bethnal Green", listOf("Central")), TestData("Blackfriars", listOf("Circle", "District")), TestData("Blackhorse Road", listOf("Victoria")), TestData("Bond Street", listOf("Central", "Jubilee")), TestData("Borough", listOf("Northern")), TestData("Boston Manor", listOf("Piccadilly")), TestData("Bounds Green", listOf("Piccadilly")), TestData("Bow Road", listOf("District", "Hammersmith & City")), TestData("Brent Cross", listOf("Northern")), TestData("Brixton", listOf("Victoria")), TestData("Bromley-by-Bow", listOf("District", "Hammersmith & City")), TestData("Buckhurst Hill", listOf("Central")), TestData("Burnt Oak", listOf("Northern")), TestData("Caledonian Road", listOf("Piccadilly")), TestData("Camden Town", listOf("Northern")), TestData("Canada Water", listOf("Jubilee")), TestData("Canary Wharf", listOf("Jubilee")), TestData("Canning Town", listOf("Jubilee")), TestData("Cannon Street", listOf("Circle", "District")), TestData("Canons Park", listOf("Jubilee")), TestData("Chalfont & Latimer", listOf("Metropolitan")), TestData("Chalk Farm", listOf("Northern")), TestData("Chancery Lane", listOf("Central")), TestData("Charing Cross", listOf("Bakerloo", "Northern")), TestData("Chesham", listOf("Metropolitan")), TestData("Chigwell", listOf("Central")), TestData("Chiswick Park", listOf("District")), TestData("Chorleywood", listOf("Metropolitan")), TestData("Clapham Common", listOf("Northern")), TestData("Clapham North", listOf("Northern")), TestData("Clapham South", listOf("Northern")), TestData("Cockfosters", listOf("Piccadilly")), TestData("Colindale", listOf("Northern")), TestData("Colliers Wood", listOf("Northern")), TestData("Covent Garden", listOf("Piccadilly")), TestData("Croxley", listOf("Metropolitan")), TestData("Dagenham East", listOf("District")), TestData("Dagenham Heathway", listOf("District")), TestData("Debden", listOf("Central")), TestData("Dollis Hill", listOf("Jubilee")), TestData("Ealing Broadway", listOf("Central", "District")), TestData("Ealing Common", listOf("District", "Piccadilly")), TestData("Earl's Court", listOf("District", "Piccadilly")), TestData("East Acton", listOf("Central")), TestData("East Finchley", listOf("Northern")), TestData("East Ham", listOf("District", "Hammersmith & City")), TestData("East Putney", listOf("District")), TestData("Eastcote", listOf("Metropolitan", "Piccadilly")), TestData("Edgware", listOf("Northern")), TestData("Edgware Road", listOf("Bakerloo", "Circle", "District", "Hammersmith & City")), TestData("Elephant & Castle", listOf("Bakerloo", "Northern")), TestData("Elm Park", listOf("District")), TestData("Embankment", listOf("Bakerloo", "Circle", "District", "Northern")), TestData("Epping", listOf("Central")), TestData("Euston", listOf("Northern", "Victoria")), TestData("Euston Square", listOf("Circle", "Hammersmith & City", "Metropolitan")), TestData("Fairlop", listOf("Central")), TestData("Farringdon", listOf("Circle", "Hammersmith & City", "Metropolitan")), TestData("Finchley Central", listOf("Northern")), TestData("Finchley Road", listOf("Jubilee", "Metropolitan")), TestData("Finsbury Park", listOf("Piccadilly", "Victoria")), TestData("Fulham Broadway", listOf("District")), TestData("Gants Hill", listOf("Central")), TestData("Gloucester Road", listOf("Circle", "District", "Piccadilly")), TestData("Golders Green", listOf("Northern")), TestData("Goldhawk Road", listOf("Circle", "Hammersmith & City")), TestData("Goodge Street", listOf("Northern")), TestData("Grange Hill", listOf("Central")), TestData("Great Portland Street", listOf("Circle", "Hammersmith & City", "Metropolitan")), TestData("Greenford", listOf("Central")), TestData("Green Park", listOf("Jubilee", "Piccadilly", "Victoria")), TestData("Gunnersbury", listOf("District")), TestData("Hainault", listOf("Central")), TestData("Hammersmith", listOf("Circle", "District", "Hammersmith & City", "Piccadilly")), TestData("Hampstead", listOf("Northern")), TestData("Hanger Lane", listOf("Central")), TestData("Harlesden", listOf("Bakerloo")), TestData("Harrow & Wealdstone", listOf("Bakerloo")), TestData("Harrow-on-the-Hill", listOf("Metropolitan")), TestData("Hatton Cross", listOf("Piccadilly")), TestData("Heathrow Terminals 1, 2, 3", listOf("Piccadilly")), TestData("Heathrow Terminal 4", listOf("Piccadilly")), TestData("Heathrow Terminal 5", listOf("Piccadilly")), TestData("Hendon Central", listOf("Northern")), TestData("High Barnet", listOf("Northern")), TestData("Highbury & Islington", listOf("Victoria")), TestData("Highgate", listOf("Northern")), TestData("High Street Kensington", listOf("Circle", "District")), TestData("Hillingdon", listOf("Metropolitan", "Piccadilly")), TestData("Holborn", listOf("Central", "Piccadilly")), TestData("Holland Park", listOf("Central")), TestData("Holloway Road", listOf("Piccadilly")), TestData("Hornchurch", listOf("District")), TestData("Hounslow Central", listOf("Piccadilly")), TestData("Hounslow East", listOf("Piccadilly")), TestData("Hounslow West", listOf("Piccadilly")), TestData("Hyde Park Corner", listOf("Piccadilly")), TestData("Ickenham", listOf("Metropolitan", "Piccadilly")), TestData("Kennington", listOf("Northern")), TestData("Kensal Green", listOf("Bakerloo")), TestData("Kensington (Olympia)", listOf("District")), TestData("Kentish Town", listOf("Northern")), TestData("Kenton", listOf("Bakerloo")), TestData("Kew Gardens", listOf("District")), TestData("Kilburn", listOf("Jubilee")), TestData("Kilburn Park", listOf("Bakerloo")), TestData("Kingsbury", listOf("Jubilee")), TestData("King's Cross St. Pancras", listOf("Circle", "Hammersmith & City", "Metropolitan", "Northern", "Piccadilly", "Victoria")), TestData("Knightsbridge", listOf("Piccadilly")), TestData("Ladbroke Grove", listOf("Circle", "Hammersmith & City")), TestData("Lambeth North", listOf("Bakerloo")), TestData("Lancaster Gate", listOf("Central")), TestData("Latimer Road", listOf("Circle", "Hammersmith & City")), TestData("Leicester Square", listOf("Northern", "Piccadilly")), TestData("Leyton", listOf("Central")), TestData("Leytonstone", listOf("Central")), TestData("Liverpool Street", listOf("Central", "Circle", "Hammersmith & City", "Metropolitan")), TestData("London Bridge", listOf("Jubilee", "Northern")), TestData("Loughton", listOf("Central")), TestData("Maida Vale", listOf("Bakerloo")), TestData("Manor House", listOf("Piccadilly")), TestData("Mansion House", listOf("Circle", "District")), TestData("Marble Arch", listOf("Central")), TestData("Marylebone", listOf("Bakerloo")), TestData("Mile End", listOf("Central", "District", "Hammersmith & City")), TestData("Mill Hill East", listOf("Northern")), TestData("Monument", listOf("Circle", "District")), TestData("Moorgate", listOf("Circle", "Hammersmith & City", "Metropolitan", "Northern")), TestData("Moor Park", listOf("Metropolitan")), TestData("Morden", listOf("Northern")), TestData("Mornington Crescent", listOf("Northern")), TestData("Neasden", listOf("Jubilee")), TestData("Newbury Park", listOf("Central")), TestData("North Acton", listOf("Central")), TestData("North Ealing", listOf("Piccadilly")), TestData("North Greenwich", listOf("Jubilee")), TestData("North Harrow", listOf("Metropolitan")), TestData("North Wembley", listOf("Bakerloo")), TestData("Northfields", listOf("Piccadilly")), TestData("Northolt", listOf("Central")), TestData("Northwick Park", listOf("Metropolitan")), TestData("Northwood", listOf("Metropolitan")), TestData("Northwood Hills", listOf("Metropolitan")), TestData("Notting Hill Gate", listOf("Central", "Circle", "District")), TestData("Oakwood", listOf("Piccadilly")), TestData("Old Street", listOf("Northern")), TestData("Osterley", listOf("Piccadilly")), TestData("Oval", listOf("Northern")), TestData("Oxford Circus", listOf("Bakerloo", "Central", "Victoria")), TestData("Paddington", listOf("Bakerloo", "Circle", "District", "Hammersmith & City")), TestData("Park Royal", listOf("Piccadilly")), TestData("Parsons Green", listOf("District")), TestData("Perivale", listOf("Central")), TestData("Piccadilly Circus", listOf("Bakerloo", "Piccadilly")), TestData("Pimlico", listOf("Victoria")), TestData("Pinner", listOf("Metropolitan")), TestData("Plaistow", listOf("District", "Hammersmith & City")), TestData("Preston Road", listOf("Metropolitan")), TestData("Putney Bridge", listOf("District")), TestData("Queen's Park", listOf("Bakerloo")), TestData("Queensbury", listOf("Jubilee")), TestData("Queensway", listOf("Central")), TestData("Ravenscourt Park", listOf("District")), TestData("Rayners Lane", listOf("Metropolitan", "Piccadilly")), TestData("Redbridge", listOf("Central")), TestData("Regent's Park", listOf("Bakerloo")), TestData("Richmond", listOf("District")), TestData("Rickmansworth", listOf("Metropolitan")), TestData("Roding Valley", listOf("Central")), TestData("Royal Oak", listOf("Circle", "Hammersmith & City")), TestData("Ruislip", listOf("Metropolitan", "Piccadilly")), TestData("Ruislip Gardens", listOf("Central")), TestData("Ruislip Manor", listOf("Metropolitan", "Piccadilly")), TestData("Russell Square", listOf("Piccadilly")), TestData("St. James's Park", listOf("Circle", "District")), TestData("St. John's Wood", listOf("Jubilee")), TestData("St. Paul's", listOf("Central")), TestData("Seven Sisters", listOf("Victoria")), TestData("Shepherd's Bush", listOf("Central")), TestData("Shepherd's Bush Market", listOf("Circle", "Hammersmith & City")), TestData("Sloane Square", listOf("Circle", "District")), TestData("Snaresbrook", listOf("Central")), TestData("South Ealing", listOf("Piccadilly")), TestData("South Harrow", listOf("Piccadilly")), TestData("South Kensington", listOf("Circle", "District", "Piccadilly")), TestData("South Kenton", listOf("Bakerloo")), TestData("South Ruislip", listOf("Central")), TestData("South Wimbledon", listOf("Northern")), TestData("South Woodford", listOf("Central")), TestData("Southfields", listOf("District")), TestData("Southgate", listOf("Piccadilly")), TestData("Southwark", listOf("Jubilee")), TestData("Stamford Brook", listOf("District")), TestData("Stanmore", listOf("Jubilee")), TestData("Stepney Green", listOf("District", "Hammersmith & City")), TestData("Stockwell", listOf("Northern", "Victoria")), TestData("Stonebridge Park", listOf("Bakerloo")), TestData("Stratford", listOf("Central", "Jubilee")), TestData("Sudbury Hill", listOf("Piccadilly")), TestData("Sudbury Town", listOf("Piccadilly")), TestData("Swiss Cottage", listOf("Jubilee")), TestData("Temple", listOf("Circle", "District")), TestData("Theydon Bois", listOf("Central")), TestData("Tooting Bec", listOf("Northern")), TestData("Tooting Broadway", listOf("Northern")), TestData("Tottenham Court Road", listOf("Central", "Northern")), TestData("Tottenham Hale", listOf("Victoria")), TestData("Totteridge & Whetstone", listOf("Northern")), TestData("Tower Hill", listOf("Circle", "District")), TestData("Tufnell Park", listOf("Northern")), TestData("Turnham Green", listOf("District", "Piccadilly")), TestData("Turnpike Lane", listOf("Piccadilly")), TestData("Upminster", listOf("District")), TestData("Upminster Bridge", listOf("District")), TestData("Upney", listOf("District")), TestData("Upton Park", listOf("District", "Hammersmith & City")), TestData("Uxbridge", listOf("Metropolitan", "Piccadilly")), TestData("Vauxhall", listOf("Victoria")), TestData("Victoria", listOf("Circle", "District", "Victoria")), TestData("Walthamstow Central", listOf("Victoria")), TestData("Wanstead", listOf("Central")), TestData("Warren Street", listOf("Northern", "Victoria")), TestData("Warwick Avenue", listOf("Bakerloo")), TestData("Waterloo", listOf("Bakerloo", "Jubilee", "Northern", "Waterloo & City")), TestData("Watford", listOf("Metropolitan")), TestData("Wembley Central", listOf("Bakerloo")), TestData("Wembley Park", listOf("Jubilee", "Metropolitan")), TestData("West Acton", listOf("Central")), TestData("West Brompton", listOf("District")), TestData("West Finchley", listOf("Northern")), TestData("West Ham", listOf("District", "Hammersmith & City", "Jubilee")), TestData("West Hampstead", listOf("Jubilee")), TestData("West Harrow", listOf("Metropolitan")), TestData("West Kensington", listOf("District")), TestData("West Ruislip", listOf("Central")), TestData("Westbourne Park", listOf("Circle", "Hammersmith & City")), TestData("Westminster", listOf("Circle", "District", "Jubilee")), TestData("White City", listOf("Central")), TestData("Whitechapel", listOf("District", "Hammersmith & City")), TestData("Willesden Green", listOf("Jubilee")), TestData("Willesden Junction", listOf("Bakerloo")), TestData("Wimbledon", listOf("District")), TestData("Wimbledon Park", listOf("District")), TestData("Wood Green", listOf("Piccadilly")), TestData("Wood Lane", listOf("Circle", "Hammersmith & City")), TestData("Woodford", listOf("Central")), TestData("Woodside Park", listOf("Northern")) ) var good = 0 var bad = 0 for (item in items) { var out = v(item.name); if (item.lines == out) { good++ } else { bad++ } } println("Results: G $good B $bad") }

Это создает список формы {x-> // Parses the data line into groups of <hashcode % 2897, and line numbers within the list below as letters val r = java.util.Base64.getDecoder().decode("eJw1VcluG0cU/BWfchoC/dbuPpJDkTM2EuSUnGmFgIlQYkAzBwNEvj1VrUSHkXp7S1W90v7y/XG/vD6ev15eX09/XK7XH8/5cn+9np8/nx/321+36+Vxen8up7e38/372+Xx7dNPn+bL48fzl9v98e18f3/uTn+e79fb7fn576+X6/n8nM/vj/vp+vz99BgH/7/4DYlu98vpH83i290k0vq8nzbqptuXSa3GDiurbT+JRztMKpUf0R1OJXdTtnKcX5b9pKXgpOZ6+Dxtsuf8sp/MEGWjEm3FURSmcI15O0npvmWiKofJsyx447FyR43nKvYFqyzrMmkIUieTilZHSWHOyJKdz0vFVamNJUvKih0/YKfpKN9RsnRfpm4LWqyJb6uKLBuxjtXGiqJr6YFobLeujOfliGV0Nh8dYcOCb9KEGJnmYWoNmTIISiorE5eRuzZlLLWOTQu8qK1tJ9XM8dUVNfWO5sR0JRQ1ScFGo/Xx24yoZesMJzH6tdJ5Nb3vmas3Y+Iex5nHJhUVS5XKMqtxG2svhYGA9Bdk64XMqBQj2qU3LpGtoJtNV1u4Kt53hL8lam7BYpsDMfInLEhrj/ll6sR/g1gMJmo+gkk6MloujBHRtuNKR5AUFIogNYLvPJP3ypF9xnEyD5TW2Jo0cCcZMr5g3itwlRIDDlNH6E5irTmYbN2JiIesu6lmjHLaiORVWQDYJRNDPlpMRpIsu8FVw2M0CzAhvyOCCrkikRresZFppM0r1SK8gl4Wihow7A9oFKSw4t6IC6lJPiuoRD1y7GUtB+ZTUc6DDL1H2PpBAdS8sDkOEdVbEQGBMjhrBcihgHGk0OSRnPW2Dllo16E5Slobs+3JezWSAaaGqttoRyG5WsiFilMWSUCMSsTwB+uI6ojuzZCX1eGgyKC10wZq3ZOusv43QOwoGoYfMs/BLX2ilX5cqTetQ5xaGm6COIyQVMU0SSnliBQlOelmZT+1xE1Ahz+lqw/dBFsVVaC9aYbJNAcV8B7yjWahNMekkmgYDLzEhoFRgVI+yMCoDoITvaDTMTphOoSgA7ToIFbHSAh1j9nhn70630MCtKTGMbACOsKSegHQW2KUkG7PD9OoAFuUVTXHGGoRtJ0C9/EmCAKVLBxJGc7opWMooS5QbfCBhUmdkIK84V3FuYffo8wykmTHEGAg+XX43fC6RhNshUY5WrIwXhJBiSbUuduwXKuUcqdHELHhGzEw8cBUpbR5SwxKxSqcTCEUHVYDwvemx4UeH07TtKFSaEZgHKjTqCmFx/U6DLAq/gcs7EQaZ4cKElpgaUPk1ohw7Rhi3sIPB8Y6hTBgA7Ve6buBVgBSxXyH4RHm1RkCW4d/AeEEm1Q=") var I = java.util.zip.Inflater() I.setInput(r) I.finished() var o = ByteArray(1846) I.inflate(o) var v= String(o).split("~") Regex("(-?[0-9]+)([A-Z]+)") // Finds all the groups .findAll(v[1])// Gets the right group .filter{ x.hashCode()%2897==it.groupValues[1].toInt()} // Gets each letter and turns it into a station name .map{ it.groupValues[2].map{ v[0] .split("|")[it-'A']}}.first() } . Finally, we merge the list by vertex:

{x->val r=java.util.Base64.getDecoder().decode("eJw1VcluG0cU/BWfchoC/dbuPpJDkTM2EuSUnGmFgIlQYkAzBwNEvj1VrUSHkXp7S1W90v7y/XG/vD6ev15eX09/XK7XH8/5cn+9np8/nx/321+36+Vxen8up7e38/372+Xx7dNPn+bL48fzl9v98e18f3/uTn+e79fb7fn576+X6/n8nM/vj/vp+vz99BgH/7/4DYlu98vpH83i290k0vq8nzbqptuXSa3GDiurbT+JRztMKpUf0R1OJXdTtnKcX5b9pKXgpOZ6+Dxtsuf8sp/MEGWjEm3FURSmcI15O0npvmWiKofJsyx447FyR43nKvYFqyzrMmkIUieTilZHSWHOyJKdz0vFVamNJUvKih0/YKfpKN9RsnRfpm4LWqyJb6uKLBuxjtXGiqJr6YFobLeujOfliGV0Nh8dYcOCb9KEGJnmYWoNmTIISiorE5eRuzZlLLWOTQu8qK1tJ9XM8dUVNfWO5sR0JRQ1ScFGo/Xx24yoZesMJzH6tdJ5Nb3vmas3Y+Iex5nHJhUVS5XKMqtxG2svhYGA9Bdk64XMqBQj2qU3LpGtoJtNV1u4Kt53hL8lam7BYpsDMfInLEhrj/ll6sR/g1gMJmo+gkk6MloujBHRtuNKR5AUFIogNYLvPJP3ypF9xnEyD5TW2Jo0cCcZMr5g3itwlRIDDlNH6E5irTmYbN2JiIesu6lmjHLaiORVWQDYJRNDPlpMRpIsu8FVw2M0CzAhvyOCCrkikRresZFppM0r1SK8gl4Wihow7A9oFKSw4t6IC6lJPiuoRD1y7GUtB+ZTUc6DDL1H2PpBAdS8sDkOEdVbEQGBMjhrBcihgHGk0OSRnPW2Dllo16E5Slobs+3JezWSAaaGqttoRyG5WsiFilMWSUCMSsTwB+uI6ojuzZCX1eGgyKC10wZq3ZOusv43QOwoGoYfMs/BLX2ilX5cqTetQ5xaGm6COIyQVMU0SSnliBQlOelmZT+1xE1Ahz+lqw/dBFsVVaC9aYbJNAcV8B7yjWahNMekkmgYDLzEhoFRgVI+yMCoDoITvaDTMTphOoSgA7ToIFbHSAh1j9nhn70630MCtKTGMbACOsKSegHQW2KUkG7PD9OoAFuUVTXHGGoRtJ0C9/EmCAKVLBxJGc7opWMooS5QbfCBhUmdkIK84V3FuYffo8wykmTHEGAg+XX43fC6RhNshUY5WrIwXhJBiSbUuduwXKuUcqdHELHhGzEw8cBUpbR5SwxKxSqcTCEUHVYDwvemx4UeH07TtKFSaEZgHKjTqCmFx/U6DLAq/gcs7EQaZ4cKElpgaUPk1ohw7Rhi3sIPB8Y6hTBgA7Ve6buBVgBSxXyH4RHm1RkCW4d/AeEEm1Q=") var I=java.util.zip.Inflater() I.setInput(r) I.finished() var o=ByteArray(1846) I.inflate(o) var v=String(o).split("~") Regex("(-?[0-9]+)([A-Z]+)").findAll(v[1]).filter{x.hashCode()%2897==it.groupValues[1].toInt()}.map{it.groupValues[2].map{v[0].split("|")[it-'A']}}.first()}

Менее чем за 90 байт мы создали почти идеальную таблицу поиска для линий каждой станции.

[ 'Circle', 'District' ]
00000001100

Исправить опечатки

К сожалению, названия некоторых станций написаны с ошибками или отсутствуют.

Нечеткое сопоставление строк должно устранить опечатки. Мы можем найти 12 неправильное написание названия станции при вводе названия станции:

msk

Замените входы "Bakerloo,Central,Circle,District,[...]".split`,`.filter((_, i) => msk >> i & 1) и msk (новые станции) с 12 , since those three stations share the same lines:

msk = parseInt(msk36, 36)

Составьте эти функции, чтобы получить поддельное название станции, найдите его строки в таблице и сохраните в 0c :

msk36 = '7c1w0o74[...]'.substr(code * 2 - 96, 2)

Исправить устаревшие

Сеть также немного устарела из-за капитального ремонта Кольцевой линии.

Если входная станция ':' or if the lookup table returns only 58 , затем добавьте code = tbl.charCodeAt(hash) to the lines.

184

Удалить лишние строки

На графике есть несколько строк, которые нас не интересуют, поэтому удалите их:

533

Вот и все!


Попробуйте! (с обходными путями)

Если вы хотите поэкспериментировать с моим решением, но у вас нет Mathematica, вы можете использовать бесплатное облако программирования Wolfram. Иди сюда, нажмите hash = id * 79 % 2777 % 2328 , then wait a moment.

К сожалению, у платформы есть некоторые ограничения, из-за которых мой код импорта блокнота не работает. Вот несколько грубых обходных путей:

Поскольку страницы примера там нет, мы можем попытаться злоупотребить функцией копирования ввода в буфер обмена из онлайн-документации. Я воспользовался инструментами разработчика своего браузера и увидел, что был сделан запрос на 3793395908848905700 (предупреждение: большой). Однако прокси-сервер платформы не разрешает домен. id = parseInt(str, 36) , so I just did it manually.

"StJamessPark"

Сначала вставьте это и нажмите сдвиг+ввод выполнить. Теперь замените str = s.replace(/\W|\d/g, '') with tbl = " 5Kd5_9 5c4[...]" .replace( /./g, c => c.repeat((n = c.charCodeAt()) < 92 || n - 91) ) .


Данные испытаний

Вызов функции s = "St. James's Park" and test it on the given data:

<select onclick="O.innerText=f(this.options[this.selectedIndex].text).join(', ')"> <option>-- Where do you want to go? --</option> <option>Acton Town</option> <option>Aldgate</option> <option>Aldgate East</option> <option>Alperton</option> <option>Amersham</option> <option>Angel</option> <option>Archway</option> <option>Arnos Grove</option> <option>Arsenal</option> <option>Baker Street</option> <option>Balham</option> <option>Bank</option> <option>Barbican</option> <option>Barking</option> <option>Barkingside</option> <option>Barons Court</option> <option>Bayswater</option> <option>Becontree</option> <option>Belsize Park</option> <option>Bermondsey</option> <option>Bethnal Green</option> <option>Blackfriars</option> <option>Blackhorse Road</option> <option>Bond Street</option> <option>Borough</option> <option>Boston Manor</option> <option>Bounds Green</option> <option>Bow Road</option> <option>Brent Cross</option> <option>Brixton</option> <option>Bromley-by-Bow</option> <option>Buckhurst Hill</option> <option>Burnt Oak</option> <option>Caledonian Road</option> <option>Camden Town</option> <option>Canada Water</option> <option>Canary Wharf</option> <option>Canning Town</option> <option>Cannon Street</option> <option>Canons Park</option> <option>Chalfont & Latimer</option> <option>Chalk Farm</option> <option>Chancery Lane</option> <option>Charing Cross</option> <option>Chesham</option> <option>Chigwell</option> <option>Chiswick Park</option> <option>Chorleywood</option> <option>Clapham Common</option> <option>Clapham North</option> <option>Clapham South</option> <option>Cockfosters</option> <option>Colindale</option> <option>Colliers Wood</option> <option>Covent Garden</option> <option>Croxley</option> <option>Dagenham East</option> <option>Dagenham Heathway</option> <option>Debden</option> <option>Dollis Hill</option> <option>Ealing Broadway</option> <option>Ealing Common</option> <option>Earl's Court</option> <option>East Acton</option> <option>East Finchley</option> <option>East Ham</option> <option>East Putney</option> <option>Eastcote</option> <option>Edgware</option> <option>Edgware Road</option> <option>Elephant & Castle</option> <option>Elm Park</option> <option>Embankment</option> <option>Epping</option> <option>Euston</option> <option>Euston Square</option> <option>Fairlop</option> <option>Farringdon</option> <option>Finchley Central</option> <option>Finchley Road</option> <option>Finsbury Park</option> <option>Fulham Broadway</option> <option>Gants Hill</option> <option>Gloucester Road</option> <option>Golders Green</option> <option>Goldhawk Road</option> <option>Goodge Street</option> <option>Grange Hill</option> <option>Great Portland Street</option> <option>Greenford</option> <option>Green Park</option> <option>Gunnersbury</option> <option>Hainault</option> <option>Hammersmith</option> <option>Hampstead</option> <option>Hanger Lane</option> <option>Harlesden</option> <option>Harrow & Wealdstone</option> <option>Harrow-on-the-Hill</option> <option>Hatton Cross</option> <option>Heathrow Terminals 1, 2, 3</option> <option>Heathrow Terminal 4</option> <option>Heathrow Terminal 5</option> <option>Hendon Central</option> <option>High Barnet</option> <option>Highbury & Islington</option> <option>Highgate</option> <option>High Street Kensington</option> <option>Hillingdon</option> <option>Holborn</option> <option>Holland Park</option> <option>Holloway Road</option> <option>Hornchurch</option> <option>Hounslow Central</option> <option>Hounslow East</option> <option>Hounslow West</option> <option>Hyde Park Corner</option> <option>Ickenham</option> <option>Kennington</option> <option>Kensal Green</option> <option>Kensington (Olympia)</option> <option>Kentish Town</option> <option>Kenton</option> <option>Kew Gardens</option> <option>Kilburn</option> <option>Kilburn Park</option> <option>Kingsbury</option> <option>King's Cross St. Pancras</option> <option>Knightsbridge</option> <option>Ladbroke Grove</option> <option>Lambeth North</option> <option>Lancaster Gate</option> <option>Latimer Road</option> <option>Leicester Square</option> <option>Leyton</option> <option>Leytonstone</option> <option>Liverpool Street</option> <option>London Bridge</option> <option>Loughton</option> <option>Maida Vale</option> <option>Manor House</option> <option>Mansion House</option> <option>Marble Arch</option> <option>Marylebone</option> <option>Mile End</option> <option>Mill Hill East</option> <option>Monument</option> <option>Moorgate</option> <option>Moor Park</option> <option>Morden</option> <option>Mornington Crescent</option> <option>Neasden</option> <option>Newbury Park</option> <option>North Acton</option> <option>North Ealing</option> <option>North Greenwich</option> <option>North Harrow</option> <option>North Wembley</option> <option>Northfields</option> <option>Northolt</option> <option>Northwick Park</option> <option>Northwood</option> <option>Northwood Hills</option> <option>Notting Hill Gate</option> <option>Oakwood</option> <option>Old Street</option> <option>Osterley</option> <option>Oval</option> <option>Oxford Circus</option> <option>Paddington</option> <option>Park Royal</option> <option>Parsons Green</option> <option>Perivale</option> <option>Piccadilly Circus</option> <option>Pimlico</option> <option>Pinner</option> <option>Plaistow</option> <option>Preston Road</option> <option>Putney Bridge</option> <option>Queen's Park</option> <option>Queensbury</option> <option>Queensway</option> <option>Ravenscourt Park</option> <option>Rayners Lane</option> <option>Redbridge</option> <option>Regent's Park</option> <option>Richmond</option> <option>Rickmansworth</option> <option>Roding Valley</option> <option>Royal Oak</option> <option>Ruislip</option> <option>Ruislip Gardens</option> <option>Ruislip Manor</option> <option>Russell Square</option> <option>St. James's Park</option> <option>St. John's Wood</option> <option>St. Paul's</option> <option>Seven Sisters</option> <option>Shepherd's Bush</option> <option>Shepherd's Bush Market</option> <option>Sloane Square</option> <option>Snaresbrook</option> <option>South Ealing</option> <option>South Harrow</option> <option>South Kensington</option> <option>South Kenton</option> <option>South Ruislip</option> <option>South Wimbledon</option> <option>South Woodford</option> <option>Southfields</option> <option>Southgate</option> <option>Southwark</option> <option>Stamford Brook</option> <option>Stanmore</option> <option>Stepney Green</option> <option>Stockwell</option> <option>Stonebridge Park</option> <option>Stratford</option> <option>Sudbury Hill</option> <option>Sudbury Town</option> <option>Swiss Cottage</option> <option>Temple</option> <option>Theydon Bois</option> <option>Tooting Bec</option> <option>Tooting Broadway</option> <option>Tottenham Court Road</option> <option>Tottenham Hale</option> <option>Totteridge & Whetstone</option> <option>Tower Hill</option> <option>Tufnell Park</option> <option>Turnham Green</option> <option>Turnpike Lane</option> <option>Upminster</option> <option>Upminster Bridge</option> <option>Upney</option> <option>Upton Park</option> <option>Uxbridge</option> <option>Vauxhall</option> <option>Victoria</option> <option>Walthamstow Central</option> <option>Wanstead</option> <option>Warren Street</option> <option>Warwick Avenue</option> <option>Waterloo</option> <option>Watford</option> <option>Wembley Central</option> <option>Wembley Park</option> <option>West Acton</option> <option>West Brompton</option> <option>West Finchley</option> <option>West Ham</option> <option>West Hampstead</option> <option>West Harrow</option> <option>West Kensington</option> <option>West Ruislip</option> <option>Westbourne Park</option> <option>Westminster</option> <option>White City</option> <option>Whitechapel</option> <option>Willesden Green</option> <option>Willesden Junction</option> <option>Wimbledon</option> <option>Wimbledon Park</option> <option>Wood Green</option> <option>Wood Lane</option> <option>Woodford</option> <option>Woodside Park</option> </select> <pre id=O></pre> ||answer||

ES6, Node.js/Chrome, 989 977 931 892 889 887 байт

let f = s=>"Bakerloo,Central,Circle,District,Hammersmith & City,Jubilee,Metropolitan,Northern,Piccadilly,Victoria,Waterloo & City".split`,`.filter((_,i)=>parseInt('7c1w0o741s3k39w22c020c080we80y3l0a8w0t3xhs2olc7g0km87w0176r8ao2e4g0q5w0eeb753mekwx1k18'.substr(" 5Kd5_9 5c4^5];`3]3 4]4^<`Y`0^5h3 9 ;<K 9^2b<`3 Wf9 9`E 0<a;< ; 9`;]2o4b99a33d5`; 3`3jB]Kj9b55e8m5]= KmS ;]K5`9^9]<_3^0 ;]3_3]3 99;b=]K 3 Xe95`9_Qd5_0o3b;];bKf=e=b3jH_<]4d; 3g:d45eT]J_5Kk4{2q9_Kc4c<l9vD`9; 9eIc2^D]<]5a3d8`5hF 4jKhLUm3|5]: ;a5{<> :^3d5t9]5l6_A~f9h5]5b5b9hK]9]: 5l4:a5m9}4^@oHkH^3e3c1c4nBf<bHa:w=b;]AsDl; K`H~K]3d;f8r9 4n9eV]9 <^9~3n=l<]9]5]5a9kK 5 5`: =g:aHcAb2q?_2b0tAsNc;]9]9_3e5e3qAkR^Ac5bK Mc?a;9t=y2_;]5b3_2e<vOd4_9i;^C`9w;a3p:a<j9]5 7Ke:_<3 9`5_Ga4h9t8_9^>e3]H^Eg5zAe4cZ_;ePGm2 3a3".replace(/./g,c=>c.repeat((n=c[C='charCodeAt']())<92||n-91))[C](parseInt(s.replace(/\W|\d/g,''),36)*79%2777%2328)*2-96,2),36)>>i&1)

Полный набор тестов (Node.js)

Попробуйте онлайн!

Демо (Chrome)

Примечание:: Из-за несоответствий в реализации parseInt() across browsers(1), это гарантированно будет работать только на всех станциях Chrome.

s=>"Bakerloo,Central,Circle,District,Hammersmith & City,Jubilee,Metropolitan,Northern,Piccadilly,Victoria,Waterloo & City".split`,`.filter((_,i)=>parseInt('7c1w0o741s3k39w22c020c080we80y3l0a8w0t3xhs2olc7g0km87w0176r8ao2e4g0q5w0eeb753mekwx1k18'.substr(" 5Kd5_9 5c4^5];`3]3 4]4^<`Y`0^5h3 9 ;<K 9^2b<`3 Wf9 9`E 0<a;< ; 9`;]2o4b99a33d5`; 3`3jB]Kj9b55e8m5]= KmS ;]K5`9^9]<_3^0 ;]3_3]3 99;b=]K 3 Xe95`9_Qd5_0o3b;];bKf=e=b3jH_<]4d; 3g:d45eT]J_5Kk4{2q9_Kc4c<l9vD`9; 9eIc2^D]<]5a3d8`5hF 4jKhLUm3|5]: ;a5{<> :^3d5t9]5l6_A~f9h5]5b5b9hK]9]: 5l4:a5m9}4^@oHkH^3e3c1c4nBf<bHa:w=b;]AsDl; K`H~K]3d;f8r9 4n9eV]9 <^9~3n=l<]9]5]5a9kK 5 5`: =g:aHcAb2q?_2b0tAsNc;]9]9_3e5e3qAkR^Ac5bK Mc?a;9t=y2_;]5b3_2e<vOd4_9i;^C`9w;a3p:a<j9]5 7Ke:_<3 9`5_Ga4h9t8_9^>e3]H^Eg5zAe4cZ_;ePGm2 3a3".replace(/./g,c=>c.repeat((n=c[C='charCodeAt']())<92||n-91))[C](parseInt(s.replace(/\W|\d/g,''),36)*79%2777%2328)*2-96,2),36)>>i&1) f = %; testData = <|"Acton Town" -> {"District", "Piccadilly"}, "Aldgate" -> {"Circle", "Metropolitan"}, "Aldgate East" -> {"District", "Hammersmith & City"}, "Alperton" -> {"Piccadilly"}, "Amersham" -> {"Metropolitan"}, "Angel" -> {"Northern"}, "Archway" -> {"Northern"}, "Arnos Grove" -> {"Piccadilly"}, "Arsenal" -> {"Piccadilly"}, "Baker Street" -> {"Bakerloo", "Circle", "Hammersmith & City", "Jubilee", "Metropolitan"}, "Balham" -> {"Northern"}, "Bank" -> {"Central", "Northern", "Waterloo & City"}, "Barbican" -> {"Circle", "Hammersmith & City", "Metropolitan"}, "Barking" -> {"District", "Hammersmith & City"}, "Barkingside" -> {"Central"}, "Barons Court" -> {"District", "Piccadilly"}, "Bayswater" -> {"Circle", "District"}, "Becontree" -> {"District"}, "Belsize Park" -> {"Northern"}, "Bermondsey" -> {"Jubilee"}, "Bethnal Green" -> {"Central"}, "Blackfriars" -> {"Circle", "District"}, "Blackhorse Road" -> {"Victoria"}, "Bond Street" -> {"Central", "Jubilee"}, "Borough" -> {"Northern"}, "Boston Manor" -> {"Piccadilly"}, "Bounds Green" -> {"Piccadilly"}, "Bow Road" -> {"District", "Hammersmith & City"}, "Brent Cross" -> {"Northern"}, "Brixton" -> {"Victoria"}, "Bromley-by-Bow" -> {"District", "Hammersmith & City"}, "Buckhurst Hill" -> {"Central"}, "Burnt Oak" -> {"Northern"}, "Caledonian Road" -> {"Piccadilly"}, "Camden Town" -> {"Northern"}, "Canada Water" -> {"Jubilee"}, "Canary Wharf" -> {"Jubilee"}, "Canning Town" -> {"Jubilee"}, "Cannon Street" -> {"Circle", "District"}, "Canons Park" -> {"Jubilee"}, "Chalfont & Latimer" -> {"Metropolitan"}, "Chalk Farm" -> {"Northern"}, "Chancery Lane" -> {"Central"}, "Charing Cross" -> {"Bakerloo", "Northern"}, "Chesham" -> {"Metropolitan"}, "Chigwell" -> {"Central"}, "Chiswick Park" -> {"District"}, "Chorleywood" -> {"Metropolitan"}, "Clapham Common" -> {"Northern"}, "Clapham North" -> {"Northern"}, "Clapham South" -> {"Northern"}, "Cockfosters" -> {"Piccadilly"}, "Colindale" -> {"Northern"}, "Colliers Wood" -> {"Northern"}, "Covent Garden" -> {"Piccadilly"}, "Croxley" -> {"Metropolitan"}, "Dagenham East" -> {"District"}, "Dagenham Heathway" -> {"District"}, "Debden" -> {"Central"}, "Dollis Hill" -> {"Jubilee"}, "Ealing Broadway" -> {"Central", "District"}, "Ealing Common" -> {"District", "Piccadilly"}, "Earl's Court" -> {"District", "Piccadilly"}, "East Acton" -> {"Central"}, "East Finchley" -> {"Northern"}, "East Ham" -> {"District", "Hammersmith & City"}, "East Putney" -> {"District"}, "Eastcote" -> {"Metropolitan", "Piccadilly"}, "Edgware" -> {"Northern"}, "Edgware Road" -> {"Bakerloo", "Circle", "District", "Hammersmith & City"}, "Elephant & Castle" -> {"Bakerloo", "Northern"}, "Elm Park" -> {"District"}, "Embankment" -> {"Bakerloo", "Circle", "District", "Northern"}, "Epping" -> {"Central"}, "Euston" -> {"Northern", "Victoria"}, "Euston Square" -> {"Circle", "Hammersmith & City", "Metropolitan"}, "Fairlop" -> {"Central"}, "Farringdon" -> {"Circle", "Hammersmith & City", "Metropolitan"}, "Finchley Central" -> {"Northern"}, "Finchley Road" -> {"Jubilee", "Metropolitan"}, "Finsbury Park" -> {"Piccadilly", "Victoria"}, "Fulham Broadway" -> {"District"}, "Gants Hill" -> {"Central"}, "Gloucester Road" -> {"Circle", "District", "Piccadilly"}, "Golders Green" -> {"Northern"}, "Goldhawk Road" -> {"Circle", "Hammersmith & City"}, "Goodge Street" -> {"Northern"}, "Grange Hill" -> {"Central"}, "Great Portland Street" -> {"Circle", "Hammersmith & City", "Metropolitan"}, "Greenford" -> {"Central"}, "Green Park" -> {"Jubilee", "Piccadilly", "Victoria"}, "Gunnersbury" -> {"District"}, "Hainault" -> {"Central"}, "Hammersmith" -> {"Circle", "District", "Hammersmith & City", "Piccadilly"}, "Hampstead" -> {"Northern"}, "Hanger Lane" -> {"Central"}, "Harlesden" -> {"Bakerloo"}, "Harrow & Wealdstone" -> {"Bakerloo"}, "Harrow-on-the-Hill" -> {"Metropolitan"}, "Hatton Cross" -> {"Piccadilly"}, "Heathrow Terminals 1, 2, 3" -> {"Piccadilly"}, "Heathrow Terminal 4" -> {"Piccadilly"}, "Heathrow Terminal 5" -> {"Piccadilly"}, "Hendon Central" -> {"Northern"}, "High Barnet" -> {"Northern"}, "Highbury & Islington" -> {"Victoria"}, "Highgate" -> {"Northern"}, "High Street Kensington" -> {"Circle", "District"}, "Hillingdon" -> {"Metropolitan", "Piccadilly"}, "Holborn" -> {"Central", "Piccadilly"}, "Holland Park" -> {"Central"}, "Holloway Road" -> {"Piccadilly"}, "Hornchurch" -> {"District"}, "Hounslow Central" -> {"Piccadilly"}, "Hounslow East" -> {"Piccadilly"}, "Hounslow West" -> {"Piccadilly"}, "Hyde Park Corner" -> {"Piccadilly"}, "Ickenham" -> {"Metropolitan", "Piccadilly"}, "Kennington" -> {"Northern"}, "Kensal Green" -> {"Bakerloo"}, "Kensington (Olympia)" -> {"District"}, "Kentish Town" -> {"Northern"}, "Kenton" -> {"Bakerloo"}, "Kew Gardens" -> {"District"}, "Kilburn" -> {"Jubilee"}, "Kilburn Park" -> {"Bakerloo"}, "Kingsbury" -> {"Jubilee"}, "King's Cross St. Pancras" -> {"Circle", "Hammersmith & City", "Metropolitan", "Northern", "Piccadilly", "Victoria"}, "Knightsbridge" -> {"Piccadilly"}, "Ladbroke Grove" -> {"Circle", "Hammersmith & City"}, "Lambeth North" -> {"Bakerloo"}, "Lancaster Gate" -> {"Central"}, "Latimer Road" -> {"Circle", "Hammersmith & City"}, "Leicester Square" -> {"Northern", "Piccadilly"}, "Leyton" -> {"Central"}, "Leytonstone" -> {"Central"}, "Liverpool Street" -> {"Central", "Circle", "Hammersmith & City", "Metropolitan"}, "London Bridge" -> {"Jubilee", "Northern"}, "Loughton" -> {"Central"}, "Maida Vale" -> {"Bakerloo"}, "Manor House" -> {"Piccadilly"}, "Mansion House" -> {"Circle", "District"}, "Marble Arch" -> {"Central"}, "Marylebone" -> {"Bakerloo"}, "Mile End" -> {"Central", "District", "Hammersmith & City"}, "Mill Hill East" -> {"Northern"}, "Monument" -> {"Circle", "District"}, "Moorgate" -> {"Circle", "Hammersmith & City", "Metropolitan", "Northern"}, "Moor Park" -> {"Metropolitan"}, "Morden" -> {"Northern"}, "Mornington Crescent" -> {"Northern"}, "Neasden" -> {"Jubilee"}, "Newbury Park" -> {"Central"}, "North Acton" -> {"Central"}, "North Ealing" -> {"Piccadilly"}, "North Greenwich" -> {"Jubilee"}, "North Harrow" -> {"Metropolitan"}, "North Wembley" -> {"Bakerloo"}, "Northfields" -> {"Piccadilly"}, "Northolt" -> {"Central"}, "Northwick Park" -> {"Metropolitan"}, "Northwood" -> {"Metropolitan"}, "Northwood Hills" -> {"Metropolitan"}, "Notting Hill Gate" -> {"Central", "Circle", "District"}, "Oakwood" -> {"Piccadilly"}, "Old Street" -> {"Northern"}, "Osterley" -> {"Piccadilly"}, "Oval" -> {"Northern"}, "Oxford Circus" -> {"Bakerloo", "Central", "Victoria"}, "Paddington" -> {"Bakerloo", "Circle", "District", "Hammersmith & City"}, "Park Royal" -> {"Piccadilly"}, "Parsons Green" -> {"District"}, "Perivale" -> {"Central"}, "Piccadilly Circus" -> {"Bakerloo", "Piccadilly"}, "Pimlico" -> {"Victoria"}, "Pinner" -> {"Metropolitan"}, "Plaistow" -> {"District", "Hammersmith & City"}, "Preston Road" -> {"Metropolitan"}, "Putney Bridge" -> {"District"}, "Queen's Park" -> {"Bakerloo"}, "Queensbury" -> {"Jubilee"}, "Queensway" -> {"Central"}, "Ravenscourt Park" -> {"District"}, "Rayners Lane" -> {"Metropolitan", "Piccadilly"}, "Redbridge" -> {"Central"}, "Regent's Park" -> {"Bakerloo"}, "Richmond" -> {"District"}, "Rickmansworth" -> {"Metropolitan"}, "Roding Valley" -> {"Central"}, "Royal Oak" -> {"Circle", "Hammersmith & City"}, "Ruislip" -> {"Metropolitan", "Piccadilly"}, "Ruislip Gardens" -> {"Central"}, "Ruislip Manor" -> {"Metropolitan", "Piccadilly"}, "Russell Square" -> {"Piccadilly"}, "St. James's Park" -> {"Circle", "District"}, "St. John's Wood" -> {"Jubilee"}, "St. Paul's" -> {"Central"}, "Seven Sisters" -> {"Victoria"}, "Shepherd's Bush" -> {"Central"}, "Shepherd's Bush Market" -> {"Circle", "Hammersmith & City"}, "Sloane Square" -> {"Circle", "District"}, "Snaresbrook" -> {"Central"}, "South Ealing" -> {"Piccadilly"}, "South Harrow" -> {"Piccadilly"}, "South Kensington" -> {"Circle", "District", "Piccadilly"}, "South Kenton" -> {"Bakerloo"}, "South Ruislip" -> {"Central"}, "South Wimbledon" -> {"Northern"}, "South Woodford" -> {"Central"}, "Southfields" -> {"District"}, "Southgate" -> {"Piccadilly"}, "Southwark" -> {"Jubilee"}, "Stamford Brook" -> {"District"}, "Stanmore" -> {"Jubilee"}, "Stepney Green" -> {"District", "Hammersmith & City"}, "Stockwell" -> {"Northern", "Victoria"}, "Stonebridge Park" -> {"Bakerloo"}, "Stratford" -> {"Central", "Jubilee"}, "Sudbury Hill" -> {"Piccadilly"}, "Sudbury Town" -> {"Piccadilly"}, "Swiss Cottage" -> {"Jubilee"}, "Temple" -> {"Circle", "District"}, "Theydon Bois" -> {"Central"}, "Tooting Bec" -> {"Northern"}, "Tooting Broadway" -> {"Northern"}, "Tottenham Court Road" -> {"Central", "Northern"}, "Tottenham Hale" -> {"Victoria"}, "Totteridge & Whetstone" -> {"Northern"}, "Tower Hill" -> {"Circle", "District"}, "Tufnell Park" -> {"Northern"}, "Turnham Green" -> {"District", "Piccadilly"}, "Turnpike Lane" -> {"Piccadilly"}, "Upminster" -> {"District"}, "Upminster Bridge" -> {"District"}, "Upney" -> {"District"}, "Upton Park" -> {"District", "Hammersmith & City"}, "Uxbridge" -> {"Metropolitan", "Piccadilly"}, "Vauxhall" -> {"Victoria"}, "Victoria" -> {"Circle", "District", "Victoria"}, "Walthamstow Central" -> {"Victoria"}, "Wanstead" -> {"Central"}, "Warren Street" -> {"Northern", "Victoria"}, "Warwick Avenue" -> {"Bakerloo"}, "Waterloo" -> {"Bakerloo", "Jubilee", "Northern", "Waterloo & City"}, "Watford" -> {"Metropolitan"}, "Wembley Central" -> {"Bakerloo"}, "Wembley Park" -> {"Jubilee", "Metropolitan"}, "West Acton" -> {"Central"}, "West Brompton" -> {"District"}, "West Finchley" -> {"Northern"}, "West Ham" -> {"District", "Hammersmith & City", "Jubilee"}, "West Hampstead" -> {"Jubilee"}, "West Harrow" -> {"Metropolitan"}, "West Kensington" -> {"District"}, "West Ruislip" -> {"Central"}, "Westbourne Park" -> {"Circle", "Hammersmith & City"}, "Westminster" -> {"Circle", "District", "Jubilee"}, "White City" -> {"Central"}, "Whitechapel" -> {"District", "Hammersmith & City"}, "Willesden Green" -> {"Jubilee"}, "Willesden Junction" -> {"Bakerloo"}, "Wimbledon" -> {"District"}, "Wimbledon Park" -> {"District"}, "Wood Green" -> {"Piccadilly"}, "Wood Lane" -> {"Circle", "Hammersmith & City"}, "Woodford" -> {"Central"}, "Woodside Park" -> {"Northern"}|>; KeyValueMap[{#, f[#] == #2} &, testData] // Grid

(1) Из спецификации: Пусть mathInt будет целочисленным математическим значением, которое представлено буквой Z в системе счисления R [...]. Если R не равно 2, 4, 8, 10, 16 или 32, то mathInt может быть приближением, зависящим от реализации. к математическому целочисленному значению, которое представлено буквой Z в системе счисления R.


Как?

Ниже приведен пошаговый пример декодирования входных данных. f .

Шаг №1

Сначала мы увеличиваем основную таблицу поиска (с 503 до 2328 байт), расширяя все ее символы заполнения. Эти символы кодируются кодом ASCII больше 92, тогда как полезные данные используют диапазон 48–90.

gWorkaround

Шаг №2

Удалим все неалфавитные символы из входной строки:

<<ExamplePages/TripPlanning.nb

что дает gWorkaround = ToExpression[ FirstCase[ Import["http://140.177.205.163/language/example/Files/TripPlanning.en/i_1.txt", {"HTML","XMLObject"}], XMLElement["pre", _, {a_}] :> a, ,-1 ], InputForm, Hold]; .

Шаг №3

Мы анализируем полученную строку как величину по основанию 36:

reference.wolfram.com

что дает http://reference.wolfram.com/language/example/Files/TripPlanning.en/i_1.txt (this is the approximated result returned by Хром V8).

Шаг №4

Вычисляем хеш-значение:

Create a New Notebook

что дает DeleteCases[..., "Overground"|"Docklands Light Rail"] .

Примечание:: Из-за потери точности этот результат математически неверен (он должен быть If[x <> r[[1]] // StringFreeQ@"sm", {}, {"Circle"}] ⋃ r ). But the lookup table was -- of course -- built the same way, so that's the one we're expecting.

Шаг №5

Мы получаем код ASCII символа в этой позиции в основной таблице поиска:

"Circle"

что дает {"Hammersmith & City"} (this is the character "Hammersmith" ).

Шаг №6

Мы используем это значение для извлечения двухсимвольной строки из вторичной таблицы поиска:

r=t@@Nearest[Keys@t]@StringReplace[__~~"d Lane"|"ket"->"Royal Oak"]@x

что дает r .

Шаг №7

Мы анализируем эту строку как величину по основанию 36:

StringReplace[__ ~~ "d Lane" | "ket" -> "Royal Oak"]

что дает "Royal Oak" .

Шаг №8

Наконец, мы фильтруем список станций в соответствии с битами, установленными в "Shepherd's Bush Market" , starting with the least significant one:

"Wood Lane"

В нашем примере Nearest[Keys@t] holds Nearest , что <| "Embankment" -> {"Bakerloo", "Circle", "District", "Northern"}, "Waterloo" -> {"Bakerloo", "Jubilee", "Northern", "Waterloo & City"}, "Brondesbury" -> {"Overground"}, ... |> in binary. So we keep the 3rd and 4th stations, which leads to the final result: t=Merge[Cases[<<ExamplePages/TripPlanning.nb,_@s__~_~{_->l_}:>(#->l&/@{s}),-1],Union@@#&] .

 

Innula


Рег
23 Jan, 2007

Тем
89

Постов
185

Баллов
680
  • 26, Oct 2024
  • #3

Котлин, 2271 2270 2000 1694 байт

t=Merge[Cases[...], Union@@#&];

Украшенный

{{v1 -> lines, v2 -> lines}, {v1 -> lines, v3 -> lines}, ...}

Тест

Cases[notebook, _@v__~_~{_->l_} :> (# -> l & /@ { v }), -1] [ the pattern ] [ the replacement ]

Правки

Удалены ненужные разделители труб -270 байт.

Сжато с помощью zip-инструментов -306 байт.

 

Zvers


Рег
16 Mar, 2009

Тем
56

Постов
181

Баллов
471
  • 26, Oct 2024
  • #5

Коричная жвачка, 2100 байт

Шестнадцатеричный дамп:

{v1 -> lines, v2 -> lines}

Попробуйте онлайн!

Я не сомневаюсь, что здесь можно играть в гольф много Более того, проблема заключается в отсутствии у Cinnamon Gum полных документов. (@quartata, пожалуйста, это большой шанс оказаться потрясающим языком тролля) Я мог бы покопаться в исходном коде, чтобы посмотреть, есть ли что-нибудь, что может быть полезно для этого.

Этот — это скрипт Python, который я собрал для генерации сжатой строки.

 

Las04


Рег
03 Nov, 2019

Тем
83

Постов
211

Баллов
636
  • 26, Oct 2024
  • #6

PHP, 1785 1780 1471 байт

lines

Украшенный

v2

Объяснение

Чтобы различать название станции с помощью всего лишь нескольких символов, я немного повозился и обнаружил, что если я возьму 22-й, 23-й и 24-й символ хеша MD5, то оно будет уникальным, за исключением ОДНОЙ коллизии: v1 could stand for UndirectedEdge[v1_, v2_] -> {"Lines" -> lines_} UndirectedEdge[v1_, v2_] ~Rule~ {"Lines" -> lines_} UndirectedEdge[v__] ~Rule~ {_ -> lines_} _[v__] ~Rule~ {_ -> l_ } _@v__ ~_~ {_ -> l_ } _@v__~_~{_->l_} а также для UndirectedEdge["Embankment", "Waterloo"] -> {"Lines" -> {"Bakerloo", "Northern"}} .

Для обозначения 11 названий трубных линий я просто использую шестнадцатеричные цифры от 0 до A.

Затем я создал разделенный запятыми список подстрок хеша MD5 с соответствующими цифрами строки трубки рядом с ним. Но я упустил FindFile["ExamplePages/TripPlanning.nb"] from the list to avoid the collision.

Пример: TripPlanning.nb means that whatever station who's md5'd name has the characters FullForm[g] на 22, 23 и 24 месте проходят линии метро, ​​упомянутые Graph[ {v1, v2, ...}, {e1, e2, ...}, Properties -> { v1 -> {propertyName -> propertyValue}, e1 -> {propertyName -> propertyValue}, (* one edge property *) ... } ] and Graph . Значение Properties runs tube lines Graph and PropertyValue[{g, edge}, "Lines"] .

Затем я написал простую функцию, которая проверяет ввод. MD5 хэширует его. Принимает 22-й, 23-й и 24-й символ. Сопоставляет его со списком, который я создал. И показывает соответствующие названия трубок. С ожиданием IncidenceList[g, vertex] off course, which is hardcoded to {..., "Acton Town" <-> "Chiswick Park" -> {"District"}, "Acton Town" <-> "Ealing Common" -> {"District", "Piccadilly"}, ...} , когда данная строка начинается с # -> PropertyValue[{g, #}, "Lines"] & /@ EdgeList[g] .

Правки

  • Заменено "Lines" with {"Acton Central", "Acton Town", "Aldgate", ...} за -5 символов
  • Использовал gzdeflated и кодировал base64_encoded, так что теперь я могу использовать g = FirstCase[<< ExamplePages/TripPlanning.nb, _Graph, , -1]; VertexList[g] for -309 chars
 

Dorohov


Рег
15 May, 2006

Тем
77

Постов
197

Баллов
612
  • 26, Oct 2024
  • #7

Питон 2, 1430 1418 1416 байт

Notebook[{Cell[ ... ], ... }, Saveable -> False, ...]

Попробуйте онлайн!

Объяснение Входные данные кодируются как двоичное представление (8-битный код ASCII для каждой буквы входного слова) при дополнении входного слова пробелами справа, если длина слова меньше 26. Я уже сделал такое же представление для всех возможные входные данные и найдите минимальные биты, которые различают выходные данные. Код смотрит на эти конкретные биты, чтобы принять решение о выходе.

  • -12 байт благодаря Джонатану Аллану.
  • -2 байта спасибо господину Xcoder при использовании лексикографического сравнения.
 

Avagvas


Рег
20 Oct, 2010

Тем
50

Постов
191

Баллов
491
  • 26, Oct 2024
  • #8

Джотлин 1.0, 1539 байт

Подчинение

<<ExamplePages/TripPlanning.nb

Тестовый код

t=Merge[Cases[<<ExamplePages/TripPlanning.nb,_@v__~_~{_->l_}:>(#->l&/@{v}),-1],Union@@#&]; x(r=t@@Nearest[Keys@t]@StringReplace[__~~"d Lane"|"ket"->"Royal Oak"]@x;DeleteCases[ If[x<>r[[1]]//StringFreeQ@"sm",{},{"Circle"}]⋃r,"Overground"|"Docklands Light Rail"])
 

Kyrix77


Рег
16 Nov, 2016

Тем
81

Постов
168

Баллов
613
Тем
403,760
Комментарии
400,028
Опыт
2,418,908

Интересно