Learn about Windows PowerShell
Beginner Event 1: The 100-meter dash
In the 100-meter dash, you will be given the finish times of our runners. You will be asked to sort the times and indicate the gold, silver, and bronze winners.
Working with data is the bread and butter of the IT pro. Many applications produce unformatted data—or seemingly unformatted data. What is wrong with using the old-fashioned comma-separated value (CSV) file? They are nice to have, easy to work with, and import directly into Office Excel, Word, and Access.
Like we said, CSV files are nice to have, but for this scenario, you do not have one. You have a text file with the times from the running of the 100-meter dash, and you need to write a script that will determine who wins the gold, silver, and bronze medals (the first three places, for you non-sports fans out there.) The results from the 100-meter dash are found in the Competitor's Pack in a file called 100 Meter Event.txt.
To successfully complete this scenario you will need to do the following:
· Figure out how to read the text file.
· Figure out how to read the name, country, and time from each row.
· Figure out how to sort the contents of the file by the time.
· Select the top three finishers (in a race, the smallest number is the fastest, so choose the three smallest numbers).
· Display the name, country, and time of the top three runners.
Note: You may wish to create a new file to hold the sorted data, and then read the top three lines of the file. You may want to convert the 100 Meter Event.txt file into a CSV file before you attempt to sort it. You do not need to include code or scripts that do this if you do not want to do so.
Advanced Event 1: The 100-meter dash
The 100-meter dash event is the shortest outdoor distance. In this event, you will be required to read a text file and to determine the shortest lines of text that it contains.
In this event, you will be required to read the Personal Information Cards_ADV1.txt file in the Competitor’s Pack and determine the shortest lines of text that the file contains. You will need to display to the console the first three shortest lines.
Here is a quick write-up of my Event 1 answer for the Advanced Event. I've written a powershell one-liner.
re: Advanced 1
Is it me or does the advanced seem significantly easier than the beginners event?
I assume that by shortest lines you mean the lines with the least number of characters in it.
There are a number of lines in the data file that contain 0 characters or simply a space. Personally I didn't consider those to be shortest lines of text.
All the Scripting Games links in one location! Let the learning begin. Review Submitted Scripts Event
( Note : These solutions are written for Event 1 .) Beginner Event 1: The 100-Meter Dash In the 100-meter