Constrained random points on a circle: Difference between revisions
Content added Content deleted
(Added Kotlin) |
|||
Line 1,634: | Line 1,634: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
|||
This solution uses the "pick random x, y and cull" rather than the "calculate valid and choose randomly" approach. |
This solution uses the "pick random x, y and cull" rather than the "calculate valid and choose randomly" approach. |
||
<lang julia>function printcircle(lo::Integer, hi::Integer, ndots::Integer; pad::Integer = 2) |
|||
<lang Julia> |
|||
⚫ | |||
const LO = 10 |
|||
i = 0 |
|||
⚫ | |||
const GOAL = 100 |
|||
⚫ | |||
if lo ^ 2 - 1 < x ^ 2 + y ^ 2 < hi ^ 2 + 1 |
|||
⚫ | |||
⚫ | |||
i = 0 |
|||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
# print |
|||
for i in 1:(2hi + 1) |
|||
⚫ | |||
⚫ | |||
println(" " ^ pad, join(row)) |
|||
⚫ | |||
end |
|||
return canvas |
|||
end |
end |
||
printcircle(10, 15, 100)</lang> |
|||
for i in 1:(2HI+1) |
|||
⚫ | |||
⚫ | |||
</lang> |
|||
{{out}} |
{{out}} |