I just got a job as a postman and I need your help to keep it. I have to order a lot of mails before I go out to deliver them.
Streets are numbered strictly sequentially, starting with 1 at the start of the street, and continuing in order skipping no numbers until the end, with odd numbers on the left side and evens on the right side. Plus houses were added later so we may also have letters appended to the civic number.
The chest contains all mail of the city so I have to choose only mails of my street.
I need your help to order the mails faster.
What I ask you is to write a function or full program taking:
- A street name.
- A list of civic numbers ordered following my path.
- A list of addresses (representing the mail chest).
And output a list of addresses containing only the ones of my street, ordered following the list of civic numbers.
An address has the form :
Person Name/n
CivicN Street Name
Where CivicN is a number that can be followed by a '/' and an UPPERCASE LETTER (10 10/B). If you prefer, lowercase is acceptable.
If Streets Names overlaps they are considered different streets:
Church Road != Saint Lorenz Church Road
We omit the rest of the address for simplicity (assuming it is the same for every mail)
Letters must be delivered fast so shortest answer wins.
EXAMPLE:
Layout :
1 1/B 3 5 7 9 11 13
==============================
2 4 4/B 6
Input :
"Tea Avenue"
["1","1/B","2","4","3","5","7","4/B","6","9","11","13"]
["Mrs. Pie O. Pinky\n6 Tea Avenue","Ms. Kita I. Omeeha\n6 Tea Avenue","Mr. Raile A. Lee\n26 Uea Grove","Odd O. Nic\n76 Mira Road","Mrs. Fuel Tee\n78 Uea Grove","Ny O. Ondip\n55 Uea Grove","Mrs. Black\n67 Uea Grove","Ollie E.\n11 Tea Avenue","Mr. Urna Li\n75 Mira Road","Ms. Polly\n2 Tea Avenue"]
Output :
Ms. Polly
2 Tea Avenue
Mrs. Pie O. Pinky
6 Tea Avenue
Ms. Kita I. Omeeha
6 Tea Avenue
Ollie E.
11 Tea Avenue
Input :
"Church Road"
["1","3","5","5/B","2","4","7","7/B","6","9","9/B","11","11/B"]
["Billy Ray V.\n5 Church Roadside East","Ms. Mia\n5 Church Road","Mrs. Dadeos\n9/B Church Road","Dr. Ymin U.\n3 Church Road","Atty. Nerou\n3 Church Road","Ollie A. Chaim\n6 Saint Lorenz Church Road","Ms. Rose\n5 Church Road","Alf Taohy\n79 Berry Road","Ms. Ootr E.\n5 Saint Lorenz Church Road","Lol E.\n21 Berry Road","Ms. Norton\n2 Church Road"]
Output :
Dr. Ymin U.
3 Church Road
Atty. Nerou
3 Church Road
Ms. Mia
5 Church Road
Ms. Rose
5 Church Road
Ms. Norton
2 Church Road"
Mrs. Dadeos
9/B Church Road
Test generator: Try it online! Change string_wrapper_left/right and separator to modify formatting.
Rules :
- Standard loopholes are forbidden.
- Standard input/output methods.
- Shortest answer in bytes wins.