Skip to content

Instantly share code, notes, and snippets.

@cdhunt
Created March 1, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdhunt/5c9a569aad952b1a4d96 to your computer and use it in GitHub Desktop.
Save cdhunt/5c9a569aad952b1a4d96 to your computer and use it in GitHub Desktop.
Beating Hadoop with Posh
Black White Tie RunTime
----- ----- --- -------
2853633 3762820 3260741 6 minutes, 45 seconds, 347 milliseconds
# http://foxdeploy.com/2016/03/01/powershell-challenge-beating-hadoop-with-posh/
# Most of the code is output formatting; the processing is a one-liner with v1 cmdlets
$start = [DateTime]::Now
$results = Get-ChildItem C:\Temp\ChessData-master -Recurse -filter *.pgn | Select-String -Pattern "Result" | Group-Object Line -NoElement
$black = $results.Where({$_.Name -eq '[Result "0-1"]'}) | Select-Object -ExpandProperty Count
$white = $results.Where({$_.Name -eq '[Result "1-0"]'}) | Select-Object -ExpandProperty Count
$tie = $results.Where({$_.Name -eq '[Result "1/2-1/2"]'}) | Select-Object -ExpandProperty Count
[PSCustomObject]@{Black=$black; White=$white; Tie=$tie; RunTime=([DateTime]::Now - $start)} | Write-Output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment