## ## use same unit of measure for each dimension. ## function guess-numberofskittles { param( $ContainerXDimension = $(throw "Need the container X dimension"), $ContainerYDimension = $(throw "Need the container Y dimension"), $ContainerZDimension = $(throw "Need the container Z dimension"), $SkittleShortRadius = 3, $SkittleLongRadius = 6 ); [decimal]$ContainerVolume = $ContainerXDimension * $ContainerYDimension * $ContainerZDimension; [decimal]$OneSkittleVolume = ([decimal] 4 / [decimal] 3) * ([Math]::PI * [Math]::Pow( $SkittleShortRadius, 2) * $SkittleLongRadius); [decimal]$MaxByVolume = $ContainerVolume / $OneSkittleVolume; [decimal]$TightestPossiblePacking = $MaxByVolume * [decimal] 0.74; [decimal]$VeryLoosePacking = $MaxByVolume * [decimal] 0.60; [decimal]$AveragePacking = $VeryLoosePacking + (($TightestPossiblePacking-$VeryLoosePacking) / 4); $return = @{ Answer = [int] $AveragePacking ContainerVolume = [int] $ContainerVolume OneSkittleVolume = [int] $OneSkittleVolume Range = @{ Perfect = [int] $TightestPossiblePacking Normal = [int] $AveragePacking Loose = [int] $VeryLoosePacking } } return $return }