Di Suatu Tempat Di Tabung… Tapi Di Jalur Mana?

26

The Tabung London Underground AKA The adalah kereta api bawah tanah tertua di dunia, saat ini terdiri dari sebelas garis * melayani 267 stasiun bernama (ketat 269 stasiun ** karena "Edgware Road" dan "Hammersmith" masing-masing menempati dua lokasi)

Tantangan

Keluarkan nama-nama jalur yang melayani stasiun yang diberi nama sebagai masukan.

Input:
String atau daftar karakter

  • Ini dapat dianggap sebagai nama stasiun yang valid (seperti yang tercantum dalam blok-kode di bawah).

  • Anda dapat mengasumsikan bahwa apa pun &dalam input akan secara konsisten menjadi kata and(atau And) alih-alih jika Anda inginkan, cukup sebutkan dengan jelas dalam jawaban Anda.

Output: Output yang
terpisah mencantumkan daftar dari sebelas baris yang melayani stasiun itu:

  • Daftar string, daftar daftar karakter, teks tercetak, string, daftar karakter; jika ragu tanyakan.

  • Anda dapat secara konsisten menampilkan kata and(atau And) di tempat apa pun &jika Anda mau, cukup sebutkan ini dengan jelas dalam jawaban Anda.

  • Dengan peringatan bahwa jika mencetak atau mengembalikan string atau daftar karakter yang pemisah-substring yang digunakan tidak ada dalam salah satu nama baris (termasuk &atau andatau Anddigunakan) - ini karena itu tidak termasuk penggunaan karakter spasi tunggal sebagai pemisah .

Jaringan Tube :
- Catatan: Ini adalah keadaan akhir, meskipun itu mengandung kesalahan ejaan (kecuali jika ditujukan sebelum ada jawaban)

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"]

... sebelas nama garis adalah:

Bakerloo
Central
Circle
District
Hammersmith & City
Jubilee
Metropolitan
Northern
Piccadilly
Victoria
Waterloo & City

* Transportasi Untuk London juga mengelola jalur kereta api lain, beberapa juga dapat disebut sebagai bagian dari "The Tube" (kemungkinan besar "Docklands Light Railway" atau "DLR") tetapi kita harus tetap berpegang pada sebelas yang tercantum di sini.

** Halaman Wikipedia yang terhubung saat ini menyatakan 270, tapi saya percaya mereka keliru menghitung lokasi kedua Canary Wharf meskipun hanya melayani "DLR")


Tumpukan poin brownies imajiner (dan kemungkinan besar banyak upvotes juga) untuk pengiriman golf menggunakan Mornington Crescent (IDE yang kompatibel tersedia di sini )!


Ini adalah , jadi kode terpendek dalam byte menang per bahasa dan solusi terpendek menang (jangan biarkan bahasa golf membuat Anda tidak bermain golf dalam bahasa lain). Selamat bersenang-senang!

Jonathan Allan
sumber
1
Saya hanya akan meninggalkan ini di sini. Saya bahkan tidak ingin mengirimkan jawaban ini. > _> Saya tidak ... menyadari betapa ... besar ini ...
manusia
2
@icrieverytim Dapatkan sarung tangan golf Anda :)
Jonathan Allan
Jadi itu hanya ... serangkaian tabung , kan? ¯ \ _ (ツ) _ / ¯
Arnauld
2
@Arnauld Tentu saja, tidak sama sekali, ya. Anda bisa "naik tabung", Anda bisa "mengganti tabung", Anda bisa "berada di tabung yang salah", Anda bisa "mendapatkan tabung pertama" atau "mengambil tabung terakhir" ... tetapi hanya ada satu Tabung :)
Jonathan Allan
3
Sekarang nyanyikan mereka bersama Jay Foreman.
TRiG

Jawaban:

14

Mathematica 8+, 266 byte

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"])

Solusi ini awalnya memiliki jumlah byte yang sama dengan stasiun. Saya kira itu bisa golf turun 50 byte atau lebih, tapi ini sepertinya tempat yang pas untuk berhenti sekarang.


pengantar

Mathematica terkenal dengan pustaka standar yang besar dan akses ke "pangkalan pengetahuan komputer" yang besar dan bisa online. Dengan berani saya mencari Wolfram | Alpha dengan harapan dapat dengan mudah menemukan data transit yang relevan, tetapi meskipun ia memahami domain dari permintaan saya, datanya belum tersedia .

Untungnya, dokumentasi bawaan Matematika yang luas dilengkapi dengan contoh-contoh yang rapi. Beberapa halaman tersebut kebetulan menggunakan jaringan London Underground untuk menunjukkan fungsionalitas terkait grafik. Kami akan menggunakan grafik dari contoh unggulan "Perencanaan Perjalanan" karena nama pendeknya.

Berikut adalah penggunaan keren lainnya dari jaringan yang sama .

Saya tidak percaya bahwa secara terprogram mengakses dokumentasi Mathematica sendiri termasuk dalam celah "Mengambil dari sumber eksternal" .


Impor halaman contoh

Kami dapat mengimpor halaman contoh sebagai ekspresi buku catatan :

<<ExamplePages/TripPlanning.nb
Notebook[{Cell[ ... ], ... }, Saveable -> False, ...]

Dimungkinkan untuk mengekstraksi seluruh grafik dari jauh di dalam ekspresi notebook:

g = FirstCase[<< ExamplePages/TripPlanning.nb, _Graph, , -1];
VertexList[g]
{"Acton Central", "Acton Town", "Aldgate", ...}  

Perhatikan bahwa simpul grafik hanyalah nama stasiun. Tepi memiliki "Lines"properti khusus yang merupakan daftar string yang mewakili garis yang melewati antara dua stasiun:

# -> PropertyValue[{g, #}, "Lines"] & /@ EdgeList[g]
{...,
 "Acton Town" <-> "Chiswick Park" -> {"District"}, 
 "Acton Town" <-> "Ealing Common" -> {"District", "Piccadilly"},
 ...}

Sekarang, kita bisa menemukan semua garis yang melewati titik dengan mengambil semua tepi kejadiannya IncidenceList[g, vertex], memetakannya PropertyValue[{g, edge}, "Lines"], dan seterusnya.

Namun, kami akan melewati metode di atas dan menyimpan banyak byte dengan pencocokan pola untuk bagian yang relevan dari Graphkonstruktor - Propertiesopsi.

Ekstrak garis

The Graphkonstruktor memiliki format berikut:

Graph[
  {v1, v2, ...},
  {e1, e2, ...},
  Properties -> {
    v1 -> {propertyName -> propertyValue},
    e1 -> {propertyName -> propertyValue},   (* one edge property *)
    ...
  }
]

(Anda dapat melihat ini dengan memeriksa FullForm[g]atau membaca kode sumber TripPlanning.nb- untuk path lengkapnya, jalankan FindFile["ExamplePages/TripPlanning.nb"].)

Berikut adalah contoh properti satu sisi:

UndirectedEdge["Embankment", "Waterloo"] -> {"Lines" -> {"Bakerloo", "Northern"}}

Mari ubah ungkapan ini menjadi pola yang ringkas:

UndirectedEdge[v1_, v2_]  ->      {"Lines" -> lines_}
UndirectedEdge[v1_, v2_]  ~Rule~  {"Lines" -> lines_}
UndirectedEdge[v__]       ~Rule~  {_       -> lines_}
             _[v__]       ~Rule~  {_       -> l_    }
             _@v__        ~_~     {_       -> l_    }

             _@v__~_~{_->l_}

Buat tabel pencarian

Sekarang kita bisa cocok v1, v2dan lines, tapi kami ingin {v1 -> lines, v2 -> lines}. Bermanfaat, Casessecara bersamaan dapat mencocokkan suatu pola dan mengubahnya.

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

Ini menghasilkan daftar formulir {{v1 -> lines, v2 -> lines}, {v1 -> lines, v3 -> lines}, ...}. Akhirnya, kami menggabungkan daftar dengan simpul:

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

Di bawah 90 byte, kami telah menghasilkan tabel pencarian yang hampir sempurna untuk setiap saluran stasiun.

t=Merge[Cases[<<ExamplePages/TripPlanning.nb,_@s__~_~{_->l_}:>(#->l&/@{s}),-1],Union@@#&]
<| "Embankment"       -> {"Bakerloo", "Circle", "District", "Northern"},
   "Waterloo"         -> {"Bakerloo", "Jubilee", "Northern", "Waterloo & City"},
   "Brondesbury"      -> {"Overground"},
    ... |>

Perbaiki kesalahan ketik

Sayangnya, beberapa nama stasiun salah eja atau hilang.

Pencocokan string fuzzy harus mengatasi kesalahan ketik. Kami dapat menemukan Nearestnama stasiun yang salah eja ke nama stasiun masukan:

Nearest[Keys@t]

Ganti input "Wood Lane"dan "Shepherd's Bush Market"(stasiun baru) dengan "Royal Oak", karena ketiga stasiun berbagi baris yang sama:

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

Buat fungsi-fungsi itu untuk mendapatkan nama stasiun palsu, cari garisnya di tabel, dan simpan di r:

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

Memperbaiki usang

Jaringan ini juga sedikit ketinggalan zaman karena perbaikan Circle Line.

Jika stasiun input adalah "Hammersmith"atau jika tabel pencarian hanya kembali {"Hammersmith & City"}, maka tambahkan "Circle"ke baris.

If[x <> r[[1]] // StringFreeQ@"sm", {}, {"Circle"}] ⋃ r

Hapus garis asing

Grafik berisi beberapa baris yang tidak kami pedulikan, jadi hapuslah:

DeleteCases[..., "Overground"|"Docklands Light Rail"]

Itu dia!


Cobalah! (dengan solusi)

Jika Anda ingin bermain-main dengan solusi saya tetapi tidak memiliki Mathematica, Anda dapat menggunakan Cloud Programming Wolfram gratis. Buka di sini , klik Create a New Notebook, lalu tunggu sebentar.

Sayangnya, platform ini memiliki beberapa batasan yang mencegah kode saya untuk mengimpor notebook. Berikut adalah beberapa solusi sederhana:

Karena halaman contoh tidak ada di sana, kami dapat mencoba menyalahgunakan fungsi salin-input-ke-clipboard dari dokumentasi online. Saya menggunakan alat pengembang peramban dan melihat bahwa ada permintaan http://reference.wolfram.com/language/example/Files/TripPlanning.en/i_1.txt(peringatan: besar). Namun, proksi platform tidak menyelesaikan domain reference.wolfram.com, jadi saya hanya melakukannya secara manual.

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];

Tempel ini terlebih dahulu dan tekan shift+enteruntuk menjalankan. Sekarang ganti <<ExamplePages/TripPlanning.nbdengan gWorkaround.


Uji data

Panggil fungsi fdan mengujinya pada data yang diberikan:

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
hftf
sumber
1
Apakah bahasa sebenarnya dikirimkan dengan dokumentasi yang diperlukan? Jika tidak, saya sarankan judulnya adalah "Mathematica 8+ (dengan <nama dokumentasi>)", pasti menggunakan sumber daya eksternal tetapi saya melihat banyak upaya yang dilakukan (terutama karena notebook sudah ketinggalan zaman).
Jonathan Allan
Ya, Mathematica benar-benar memberikan dokumentasinya.
hftf
Jika bahasa dikirim dengan semua file contoh ini secara default maka saya tidak berpikir ada celah yang telah digunakan (saya tidak dapat memverifikasi ini karena Mathematica tidak gratis, jadi jika orang lain dapat, saya pribadi akan menghargai konfirmasi). Omong-omong, jawaban yang bagus!
Jonathan Allan
16

ES6, Node.js / Chrome, 989 977 931 892 889 887 byte

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)

Paket tes lengkap (Node.js)

Cobalah online!

Demo (Chrome)

NB : Karena inkonsistensi dalam implementasi parseInt()lintas browser (1) , ini hanya dijamin berfungsi untuk semua stasiun di Chrome.

(1) Dari spesifikasi : Misalkan mathInt menjadi nilai integer matematis yang diwakili oleh Z dalam notasi radix-R [...]. Jika R bukan 2, 4, 8, 10, 16, atau 32, maka mathInt mungkin merupakan pendekatan yang bergantung pada implementasi terhadap nilai integer matematika yang diwakili oleh Z dalam notasi radix-R.


Bagaimana?

Di bawah ini adalah contoh decoding langkah-demi-langkah untuk input s = "St. James's Park".

Langkah 1

Kami pertama-tama mengembang tabel pencarian utama (dari 503 menjadi 2.328 byte) dengan memperluas semua karakter padding-nya. Karakter-karakter ini dikodekan dengan kode ASCII lebih besar dari 92, sedangkan data payload menggunakan kisaran 48-90.

tbl = " 5Kd5_9 5c4[...]"
  .replace(
    /./g, c =>
      c.repeat((n = c.charCodeAt()) < 92 || n - 91)
  )

Langkah 2

Kami menghapus semua karakter non-alfabet dari string input:

str = s.replace(/\W|\d/g, '')

yang memberi "StJamessPark".

Langkah # 3

Kami mengurai string yang dihasilkan sebagai kuantitas base-36:

id = parseInt(str, 36)

yang memberikan 3793395908848905700(ini adalah hasil yang diperkirakan dikembalikan oleh Chrome V8 ).

Langkah # 4

Kami menghitung nilai hash:

hash = id * 79 % 2777 % 2328

yang memberi 533.

NB : Karena kehilangan presisi, hasil ini tidak benar secara matematis (seharusnya 184). Tapi tabel pencarian - tentu saja - dibangun dengan cara yang sama, jadi itulah yang kami harapkan.

Langkah # 5

Kami mengambil kode ASCII dari karakter di posisi ini di tabel pencarian utama:

code = tbl.charCodeAt(hash)

yang memberi 58(ini karakternya ':').

Langkah # 6

Kami menggunakan nilai ini untuk mengekstrak string 2 karakter dari tabel pencarian sekunder:

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

yang memberi 0c.

Langkah # 7

Kami mengurai string ini sebagai kuantitas base-36:

msk = parseInt(msk36, 36)

yang memberi 12.

Langkah # 8

Akhirnya, kami memfilter daftar stasiun sesuai dengan bit yang ditetapkan msk, dimulai dengan yang paling signifikan:

"Bakerloo,Central,Circle,District,[...]".split`,`.filter((_, i) => msk >> i & 1)

Dalam contoh kami, mskmemegang 12, yang 00000001100dalam biner. Jadi kita tetap 3 dan stasiun 4, yang mengarah ke hasil akhir: [ 'Circle', 'District' ].

Arnauld
sumber
@ JonathanAllan Tidak? Bagi saya itu kembali Northern.
Erik the Outgolfer
Anda dapat menyimpan 3 byte dengan mengompresi skrip menggunakan RegPack .
@ThePirateBay (pembaruan) Saya menyimpan 46 byte dengan meng-enkode ulang string data utama, jadi tidak ramah sama sekali dengan RegPack lagi.
Arnauld
Karena ketertarikan, apa inkonsistensi yang Anda rujuk?
Neil
1
@Neil Dari spesifikasi : Biarkan mathInt menjadi nilai integer matematika yang diwakili oleh Z dalam notasi radix-R [...]. Jika R bukan 2, 4, 8, 10, 16, atau 32, maka mathInt mungkin merupakan pendekatan yang bergantung pada implementasi terhadap nilai integer matematika yang diwakili oleh Z dalam notasi radix-R.
Arnauld
5

Kotlin , 2271 2270 2000 1694 byte

{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()}

Yg diperindahkan

{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()
}

Uji

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")
}

Suntingan

Pemisah pipa yang tidak dibutuhkan -270 bytes

Dikompresi dengan alat zip -306 byte

jrtapsell
sumber
1
TIL: Woodside Park 1337.
Jonathan Allan
Mencari untuk menggunakan alat zip Java untuk kompres string, harus mendapatkan byte down sedikit lebih
jrtapsell
5

Python 2 , 2309 2301 2218 byte

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]

Cobalah online!

-6 terima kasih kepada Tn . Xcoder .

Terlalu lama ... mungkin golf.

Erik the Outgolfer
sumber
1591 byte
mdahmoune
1813 byte Menggunakan metode pencarian yang berbeda. 1498 bytes menggunakan encoding @ mdahmoune
TFeld
1498 bytes @EriktheOutgolfer Saya entah bagaimana menyalin tautan yang salah .. Ini dia ..
TFeld
1
Lupa menghapus duplikat (beberapa stasiun dengan nama yang sama dan baris yang sama): 1708 byte dan 1434 byte
TFeld
Mari kita lanjutkan diskusi ini dalam obrolan .
Erik the Outgolfer
3

Cinnamon Gum , 2100 byte

Hexdump:

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                                ....

Cobalah online!

Saya telah tidak diragukan lagi ini bisa golfed jauh lagi, masalahnya adalah kurangnya Cinnamon Gum ini docs lengkap. (@quartata tolong ini kesempatan besar untuk menjadi troll lang yang luar biasa) Saya mungkin menggali kode sumber untuk melihat apakah ada sesuatu yang dapat bermanfaat untuk ini.

Ini adalah skrip Python yang saya hack bersama untuk menghasilkan string terkompresi.

benar-benar manusiawi
sumber
3

PHP, 1785 1780 1471 byte

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==')));

Yg diperindahkan

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";
    }
');

Penjelasan

Untuk membedakan nama stasiun dengan sesedikit karakter, saya sedikit mengotak-atik dan menemukan bahwa jika saya mengambil karakter ke-22, 23 dan 24 dari hash MD5, itu akan menjadi unik kecuali untuk SATU tabrakan: ddbbisa berdiri Heathrow Terminals 1, 2, 3dan untuk Dagenham Heathway.

Untuk merujuk pada 11 nama garis tabung, saya hanya menggunakan digit heksidimal dari 0 hingga A.

Kemudian saya membuat daftar substring hash MD5 yang dipisah koma, dengan digit garis tabung yang sesuai di sebelahnya. Tapi saya memang meninggalkan Heathrow Terminals 1, 2, 3daftar untuk menghindari tabrakan.

Contoh: fe538berarti bahwa stasiun apa pun yang namanya md5 akan memiliki karakter fe5di tempat 22, 23 dan 24, menjalankan garis tabung yang dirujuk oleh 3dan 8. Arti Acton Townmenjalankan garis tabung Districtdan Piccadilly.

Lalu saya menulis fungsi sederhana yang memeriksa input. MD5 memotongnya. Mengambil karakter ke 22, 23 dan 24. Cocokkan dengan daftar yang saya buat. Dan menunjukkan nama tabung yang sesuai. Dengan expection ddbtentu saja, yang hardcoded Piccadilly, ketika string yang diberikan dimulai dengan H.

Suntingan

  • Digantikan array()dengan []untuk -5 karakter
  • Digunakan gzdeflated dan base64_encoded kode saya, jadi sekarang saya dapat menggunakan eval(gzinflate(base64_decode()))untuk -309 karakter
nl-x
sumber
Digit hash MD5 juga heksadesimal. Seharusnya bisa dilakukan untuk mendapatkan 12 bit yang berada di tiga karakter menjadi 2 karakter ascii. Ini dapat mengurangi 1 karakter per stasiun. Tetapi kode untuk melakukan ini mungkin lebih besar daripada ide ini ...
nl-x
1

Python 2 ,  1430   1418  1416 byte

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

Cobalah online!

Penjelasan Input dikodekan sebagai representasi biner (kode ASCII 8-bit untuk setiap huruf kata input) ketika mengisi kata input dengan spasi di kanan jika panjang kata kurang dari 26. Saya sudah melakukan representasi yang sama untuk semua input yang mungkin dan temukan bit minimal yang membedakan output. Kode melihat bit-bit khusus ini untuk memutuskan output.

  • -12 byte terima kasih kepada Jonathan Allan.
  • -2 byte terima kasih kepada Tn. Xcoder saat menggunakan perbandingan leksikografis.
mdahmoune
sumber
Ini keren sekali. Bisakah Anda menggunakan karakter yang tidak diinginkan dan memiliki string yang didekode base64? Satu byte dapat disimpan dengan s=(s+' '*22)[:26]alih - alih s+=' '*(26-len(s)).
Jonathan Allan
1
... dan sembilan lainnya dengan menggarisbawahi itu dan input fetch: n=0newline for e in(input()+' '*26)[:26]:n=n*256+ord(e). Dua lagi dengan menggunakan n=i=0di bagian atas juga.
Jonathan Allan
@Jonathan Allan terima kasih banyak untuk komentar Anda. Harap bebas mengedit jawabannya :)
mdahmoune
Diedit dalam 12 byte yang disimpan. Saya tidak yakin tentang karakter yang tidak patut dicetak (saya dapatkan SyntaxError: Non-ASCII character...ketika saya mencoba melakukannya) - mungkin perlu tajuk penyandian atau sesuatu.
Jonathan Allan
1
1416 (-2 bytes) , menggunakan perbandingan lexicographical.
Tn. Xcoder
1

Jotlin 1.0 , 1539 byte

pengajuan

{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()}}

Kode uji

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)
    }
}
jrtapsell
sumber
Port of Kotlin saya menjawab Jotlin
jrtapsell