The Final Showdown
On day 6 we launched the Final Showdown. To get into this round, you had to finish in the top 15 in any of the previous days. This scenario had 2 seemingly simple task. The first was to rename a directory of e-reader files to a new naming convention, the second was to update the naming convention in the database. There were many ways to do these tasks, we saw for .. do loops in bash, awk scripts, at least one person installed php and scripted a solution. Only seven contestants finished the tasks correctly. The previous day's winners are mostly listed as DNF. Almost all issues encountered in this Final Showdown were the result of improper naming convention. Our grader script required strict adherence to the naming standards. In the rush to finish first, most participants misread the naming guidelines.
"thenaterator" held the number one spot on the leaderboard for most of the final day, only to be surpassed later in the day by "ubergeek03" who took the top spot with a time of 6 Minutes 52 seconds. DiablQ came in second place a mere second later at 6 Minutes 53 seconds.
Originally, I planed to solve this challenge with the perl rename command followed by a search and replace in the database. Most Linux distros include the perl rename command, but CentOS does not. Instead, we can use the included rename command to do the same in two steps. First, change book to e-book, then tackle the extension, we will use this same two-step technique on the database rows.
rename book e-book *.azw
rename .azw .tt *azw
Now rename the database to match, using the same two-step technique: base name, then extension.
mysql -u root -p******
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ereader |
| mysql |
| test |
+--------------------+
4 rows in set (0.04 sec)
mysql> use ereader;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_ereader |
+-------------------+
| books |
+-------------------+
1 row in set (0.00 sec)
mysql> describe books;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| book | varchar(32) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.02 sec)
mysql> update books set book = replace(book, 'book', 'e-book');
mysql> update books set book = replace(book, '.azw', '.tt');
Thanks for following along with the SXSW Linux Showdown, we had a great deal of fun hosting this challenge. We hope to get the next round of challenges out to you soon.