Monday, February 25, 2008

2008 Scripting Games - Advanced Event 2

 

Event 2: Skating on Thin Ice

$winners = cat C:\Scripts\skaters.txt | foreach {
  $item = $_.split(",")
  $scores = $item[1..7] | sort
  
  $skater = new-object psobject
  add-member -inp $skater noteproperty Name $item[0]
  add-member -inp $skater noteproperty HighestScore $scores[-1]
  add-member -inp $skater noteproperty LowestScore $scores[0]
  add-member -inp $skater noteproperty Score (($scores[1..($scores.length-2)] | measure-object -average).Average)
  add-member -inp $skater noteproperty Medal $null
  $skater
  
} | sort Score -desc | select -first 3

$winners[0].Medal="Gold medal"
$winners[1].Medal="Silver medal"
$winners[2].Medal="Bronze medal"

0..2 | foreach { "{0}: {1}, {2}" -f $winners[$_].Medal, $winners[$_].name ,$winners[$_].Score }

Results:
Gold medal: Guido Chuffart, 88.2
Silver medal: Jack Creasey, 85.8
Bronze medal: Cecilia Cornejo, 85.4
 

No comments: