Created
March 6, 2020 23:37
-
-
Save SP3269/2eb220fb5f28e1fc088f8b02afaf69eb to your computer and use it in GitHub Desktop.
Simple statistical look at the dice rolls in game of Catan using PowerShell 7
This file contains hidden or 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
$game20200305 = @' | |
44 | |
61 | |
65 | |
63 | |
41 | |
45 | |
22 | |
63 | |
23 | |
66 | |
25 | |
26 | |
26 | |
13 | |
44 | |
53 | |
41 | |
33 | |
46 | |
14 | |
26 | |
43 | |
54 | |
46 | |
11 | |
12 | |
45 | |
33 | |
55 | |
23 | |
64 | |
15 | |
11 | |
24 | |
12 | |
25 | |
14 | |
43 | |
35 | |
16 | |
24 | |
23 | |
24 | |
25 | |
12 | |
54 | |
25 | |
66 | |
23 | |
33 | |
65 | |
26 | |
15 | |
16 | |
12 | |
54 | |
64 | |
44 | |
14 | |
43 | |
55 | |
34 | |
22 | |
55 | |
24 | |
23 | |
26 | |
23 | |
64 | |
53 | |
53 | |
16 | |
11 | |
63 | |
55 | |
13 | |
12 | |
13 | |
24 | |
54 | |
43 | |
13 | |
24 | |
66 | |
53 | |
15 | |
64 | |
25 | |
26 | |
35 | |
44 | |
33 | |
54 | |
'@ | |
$data = $game20200305 | |
$rolls = -split $data | |
$normalised = $rolls | % { $one = [math]::floor($_/10); $two = $_%10; $one -gt $two ? ($two*10+$one) : $_ } | |
$singles = $rolls | % { [math]::floor($_/10); $_%10 } | |
$singles | group-object | sort-object name | select Name,Count | |
$singles | measure-object -all | |
$sums = $rolls | % { [math]::floor($_/10)+$_%10 } | |
$sums | group-object | select @{N="Sigma";E={[int]$_.Name}},Count | |
$sums | measure-object -all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment