Created
July 6, 2010 03:08
-
-
Save hammerdr/464956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Derek Hammer | |
| ; | |
| ; Code Kata #4, Part B | |
| ; Parsing football.dat and gets the lowest points spread | |
| ; and team associated with it. Done in Ioke. | |
| DATA_FORMAT = #/.*\d+\.\W(\w*)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)/ | |
| pointsFielded = method(line, | |
| DATA_FORMAT match(line)[6] toRational) | |
| pointsAllowed = method(line, | |
| DATA_FORMAT match(line)[7] toRational) | |
| pointsSpread = method(line, | |
| pointsFielded(line) - pointsAllowed(line)) | |
| teamName = method(line, | |
| DATA_FORMAT match(line)[1]) | |
| data = FileSystem readLines("football.dat") filter(line, line =~ DATA_FORMAT) | |
| minimumPointsSpread = data map(line, pointsSpread(line)) min | |
| teamPointsPairs = data map(line, [teamName(line), pointsSpread(line)]) | |
| minimumTeamPointsPair = teamPointsPairs select(pair, pair second == minimumPointsSpread) first | |
| minimumTeamPointsPair join(" ") println |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment