Created
February 14, 2022 04:17
-
-
Save nicholasjackson827/10baee339fbfb69b61dbec45005b3fb6 to your computer and use it in GitHub Desktop.
Magic Gumball Simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-StatisticsResults { | |
$NumberOfQuarters = 10; | |
$PercentageOfGettingQuarterBack = 0.5; | |
$NumberOfGumballs = 0; | |
while ($NumberOfQuarters -ne 0) { | |
$NumberOfGumballs++; | |
$RandNumber = (Get-Random -Minimum 0.0 -Maximum 1.0) | |
if ($RandNumber -lt $PercentageOfGettingQuarterBack) { | |
$NumberOfQuarters--; | |
} | |
} | |
return $NumberOfGumballs | |
} | |
1..10000 | | |
ForEach-Object { Get-StatisticsResults } | | |
Group-Object | | |
Select-Object Name,Count,@{Name="Graph";Expression={"*" * [math]::floor($_.Count / 50)}} | | |
Sort-Object Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment