Competition time
|Starting with issue 1, Linux Voice is holding monthly competitions to test out your Linux skills. The first is a grep challenge. If you’re unfamiliar with grep, there’s a great tutorial on getting started in the magazine, or you should also be able to find plenty on help online. It’s a really useful tool for working with text files, and word games are a great way to familiarise yourself with how it works. The competition’s open to all, and is an excellent way to test your grep skills.
The two winning entries (see below) will each receive a Linux Voice winners t-shirt. These will only ever be available to Linux Voice challenge winners, so there’s no better way to show off your leet Linux skills to the world.
You can see the magazine page (with a few extra grep challenges) here:
The extra challenges are (though there’s no prizes for these):
- Anagrams
- Countdown (find the longest word using only those letters)
- Encryption (solve the substitution cipher)
- Word Wheel (find as many words as you can that include the middle letter plus two or more of the outer letter)
- Word Ladder (change one letter each step to get from the top word to the bottom word
They can all be easily solved with grep (and maybe a little Bash scripting). More details are in the magazine.
The prize challenge is a little more tricky. You can find it in the image, but the full text is here for convenience:
The final challenge is something different, one we haven’t covered so far: a word search. To make matters a little easier, there are only horizontal words, and none of them are backwards. The challenge is to write a Bash script that can go in the following pipe:
cat wordsearch.txt | bash yourscript.sh
and output all of the three or more letter words from the words list (/usr/share/dict/words or usr/dict/words) that are in the file. You can use the word list here if you don’t have one on your distro. The word search text is:
zfghellohb
binarytwno
thisenthat
dfjunglwmr
scoffeeqwj
lhzniphoto
rlightovqx
yelsocketn
fbicycleow
ykerolbuha
To make things interesting, there will be two prizes, one for the smallest (in terms of characters in the Bash script, not including comments), and one for the one that runs fastest (completes execution with all the words found in the shortest time). The words must be found with a form of GNU grep (egrep, pgrep, etc.) matching a regular expression. There are few differences between versions of Bash on different Linuxes, so we’ll be testing on a fresh install of Debian Unstable. This is only likely to matter if you’re relying on particularly new or exotic features. To be eligible, your program must be licensed under an OSI-approved licence compatible with the GPL v2 or v3. We recommend using GPLv3.
All entries must be sent to ben@linuxvoice.com by 31 March, and the winner will be announced in issue 3 (and on linuxvoice.com). You don’t have to have bought a magazine to enter. In the event of a tie, the solution that was sent in first will win. In all matters, the editor’s decision will be final.
Good luck, and we look forward to seeing your entry.
Nice one guys. And to think I thought PERL was difficult to understand. But nice tutorial, and expecting some clever guy who does it all in one line.
I take it “a little Bash scripting” doesn’t mean we can use other available command line utilities…
an -w -m 8 ainpprss
😛
… actually, this looks like a good candidate in my constant search for interesting challenges to bolster my enthusiasm to learn C++. Notwithstanding just using it to launch grep, obviously.
Knew it. Must say have not come across “an” before, and if it is an anagram solver, it may not be what we are searching for. Besides with the command line utility could be called through a bash script…just figure out a way to use grep and regular expressions with it and all conditions are met.
The article in lv issue 1 confirmed my suspicions that I am in fact, stupid…
Don’t be so hard on yourself.
After all, in order to learn something new, you must admit to ignorance before you gain knowledge.
And we can all be stupid at times, that’s not to say we can’t also be clever at times.
I also had not heard of “an” before, and it may actually be a non-standard command line command.
The challenge ought to be something that any person could on any given install and system be at least expected to have a grep command of some sort (ie in the gnu or unix if you like regular set of available standard commands) so I don’t know whether use of “an” is entirely within the scope?
nevertheless, I reckon challenges of this sort are really great!
best regs,
Michael.
Um, why does need piping in from cat?
Wouldn’t you just mark your script as executable, and use the file as an argument, like
./yourscript wordsearch.txt
Exactly that pipe and making the script match *all* possible combinations of the dictionary was causing me some headaches. Could not find a single-line piped solution for this, not using xargs or anything, but I submitted a solution. I hope the other solutions will be published too on this website, as I’m curious what other people have come up with…
Agreed that it should be able to take a file as a parameter. BUT I suspect that this part of a greater plan by Ben to extend the utility further and not just confine it to text files.