Skip to content

Instantly share code, notes, and snippets.

@hammerdr
Created July 6, 2010 03:08
Show Gist options
  • Save hammerdr/464956 to your computer and use it in GitHub Desktop.
Save hammerdr/464956 to your computer and use it in GitHub Desktop.
; 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