This show has been flagged as Clean by the host.
The Dutch Railway Company occasionally has a anagram of the names of the railway stations on their services.
The image above shows which service we are on, namely the intercity direct to Breda via Schiphol Airport , and the time is 07:27.
It shows a cartoon depiction of a platform where the information sign is displaying the letters of the anagram, and today it reads "Nul Te Teer".
Under it says "Oops, the letters are mixed up. Can you guess the correct station ?"
The under it says that the next station at 07:38 will be Duivendrecht .
I wrote a script to check my guess. It consists of a function normalise_word, which takes any word, removes everything but the letters, and then converts it to lower case. Each letter is printed to it's own line, where it's sorted, and new lines are removed, to be printed as a "normalised" word.
This is used to take the List of Dutch Railway Stations from Wikipedia , to produce a list of stations and convert them to normalized names which is saved to a new file with the normalised names on the same line as the real names.
We can then just grep for the normalised version of the anagram and whatever line it was found in the normalised file, should correspond to the same line in the real file.
"Nul Te Teer" gets converted to "eeelnrttu" which is found in the normalised file, and that corresponds to " Etten-Leur "
Tell us how would you solve it ?
#!/bin/bash
# Ken Fallon - CC-0/Public Domain
station_file="ns-train-stations.txt"
# Get the station name
if [ "$#" -lt 1 ]
then
echo "ERROR: Please specify station"
exit 1
fi
function normalise_word() {
printf '%sn' "${1}"
| tr --delete --complement 'A-Za-zn'
| tr '[:upper:]' '[:lower:]'
| grep --only-matching --regexp='.'
| sort --ignore-case
| tr --delete 'n'
printf 'n'
}
station="$( normalise_word "${1}" )"
cat ${station_file} | while read word
do
normalise_word "${word}"
done > "${station_file%.*}_normalised.txt"
linenumber="$( grep --line-number --perl-regexp "^${station}$" "${station_file%.*}_normalised.txt" | awk -F ':' '{print $1}' )"
sed --quiet "${linenumber}p" ${station_file}
Unless otherwise stated, our shows are released under a Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.
The HPR Website Design is released to the Public Domain.