Advertisement
kevinrossen

Khris Davis .247 Cheat Sheet (PowerShell Script)

Mar 20th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # PowerShell Script to find all possible scenarios for Khris Davis hitting .247
  2.  
  3. $avgString = $null
  4. $outcomes = $null
  5. $atbats = 1
  6. $hits = 1
  7.  
  8. While ($atbats -lt 675) {
  9.     $atbats = $atbats + 1
  10.     # $hits = $hits + 1
  11.     $avg = [math]::Round($hits / $atbats, 3)
  12.     While ($avg -ne 0.247) {
  13.         While ($avg -gt 0.247) {
  14.             $atbats = $atbats + 1
  15.             $avg = [math]::Round($hits / $atbats, 3)
  16.         }
  17.         While ($avg -lt 0.247) {
  18.             $hits = $hits + 1
  19.             $avg = [math]::Round($hits / $atbats, 3)
  20.         }
  21.     }
  22.     $avgString = $avg.ToString().SubString($avg.ToString().length - 4, 4)
  23.     $outcomes += "Average is $avgString with $hits hits in $atbats at bats.`r`n"
  24. }
  25. $outcomes | clip
  26. $outcomes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement