Zum Hauptinhalt springen
•
YouTube Security VideosTechLinked: Sony made a hologram waifu for your desk(04.11.2026 um 18:52 Uhr)
•••
YouTube Security VideosNeil Patel: 17 Marketing Numbers You Need for 2026(04.11.2026 um 20:06 Uhr)
•
YouTube Security VideosLinus Tech Tips: Good PC Deals Still Exist!(04.11.2026 um 18:00 Uhr)
••
Podcasts & Audio BriefingsCOMPUTER BILD: Apple-Keynote: iPhone 18, iPhone Duo und die Hype-Maschine(04.11.2026 um 18:22 Uhr)
••
Windows Tipps & SecurityRTX Spark: Local AI Baby Steps and a Few Small Victories ⭐(04.11.2026 um 18:44 Uhr)
••
YouTube Security VideosTechLinked: Sony made a hologram waifu for your desk(04.11.2026 um 18:52 Uhr)
•••
YouTube Security VideosNeil Patel: 17 Marketing Numbers You Need for 2026(04.11.2026 um 20:06 Uhr)
•
YouTube Security VideosLinus Tech Tips: Good PC Deals Still Exist!(04.11.2026 um 18:00 Uhr)
••
Podcasts & Audio BriefingsCOMPUTER BILD: Apple-Keynote: iPhone 18, iPhone Duo und die Hype-Maschine(04.11.2026 um 18:22 Uhr)
••
Windows Tipps & SecurityRTX Spark: Local AI Baby Steps and a Few Small Victories ⭐(04.11.2026 um 18:44 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

HPR4763: Solving anagrams with bash

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

Beitrag
0
Seite
0
↗ Quelle (Hacker Public Radio)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

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}












Provide feedback on this episode.

Intelligence Digest — free The top security news daily · unsubscribe anytime
Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
No reader ratings yet
Was this page helpful?
0
Jetzt Bewertung abgeben
🟢 Niedrig (1-3.9) 🟡 Mittel (4.0-6.9) 🔴 Hoch (7.0-8.9) Kritisch (9.0-10.0)

Related story clusters & sources (vector AI)

Pull to refresh
Nächster Beitrag