Task

Generate 100 <x,y> coordinate pairs such that x and y are integers sampled from the uniform distribution with the condition that 




10
≤



x

2


+

y

2




≤
15


{\displaystyle 10\leq {\sqrt {x^{2}+y^{2}}}\leq 15}

. 
Then display/plot them. The outcome should be a "fuzzy" circle. The actual number of points plotted may be less than 100, given that some pairs may be generated more than once.

There are several possible approaches to accomplish this. Here are two possible algorithms.

1) Generate random pairs of integers and filter out those that don't satisfy this condition:





10
≤



x

2


+

y

2




≤
15


{\displaystyle 10\leq {\sqrt {x^{2}+y^{2}}}\leq 15}

.
2) Precalculate the set of all possible points (there are 404 of them) and select randomly from this set.




'   RC Constrained Random Points on a Circle
 
nomainwin
 
WindowWidth  =400
WindowHeight =430
 
open "Constrained Random Points on a Circle" for graphics_nsb as #w
 
#w "trapclose [quit]"
#w "down ; size 7 ; color red ; fill black"
 
for i =1 to 1000
  do
     x =int( 30 *rnd( 1)) -15
     y =int( 30 *rnd( 1)) -15
  loop until IsInRange( x, y) =1
  #w "set "; 200 +10 *x; " "; 200 - 10 *y
next
 
wait
 
function IsInRange( x, y)
  z =sqr( x*x +y*y)
  if 10 <=z and z <=15 then IsInRange =1 else IsInRange =0
end function
 
[quit]
close #w
end