Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $strArray = $stringInput -split '\r\n\s'
- $elfId = 1
- $elfResults = foreach ($row in $strArray) {
- $elfCaloriesStrs,$elfCalories = $null
- $elfCaloriesStrs = $row -split '\s' | Where {-not [string]::IsNullOrWhiteSpace($_)}
- $elfCalories = ($elfCaloriesStrs | foreach {$_ -as [int]} | Measure-Object -Sum).Sum
- [pscustomobject]@{
- elf = $elfId
- Calories = $elfCalories
- }
- $elfId++
- }
- $elfResults | Sort Calories | Select -Last 1
- # 2
- ($elfResults | Sort Calories -Descending | Select -First 3 | Measure-Object -Sum -Property Calories).Sum
Advertisement
Add Comment
Please, Sign In to add comment