RosettaCodeData/Task/Constrained-random-points-on-a-circle/PowerShell/constrained-random-points-on-a-circle.psh
2016-12-05 22:15:40 +01:00

18 lines
450 B
Text

$MinR2 = 10 * 10
$MaxR2 = 15 * 15
$Points = @{}
While ( $Points.Count -lt 100 )
{
$X = Get-Random -Minimum -16 -Maximum 17
$Y = Get-Random -Minimum -16 -Maximum 17
$R2 = $X * $X + $Y * $Y
If ( $R2 -ge $MinR2 -and $R2 -le $MaxR2 -and "$X,$Y" -notin $Points.Keys )
{
$Points += @{ "$X,$Y" = 1 }
}
}
ForEach ( $Y in -16..16 ) { ( -16..16 | ForEach { ( " ", "*" )[[int]$Points["$_,$Y"]] } ) -join '' }