June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,18 +1,19 @@
const LO = 10
const HI = 15
const GOAL = 100
canvas = falses(2HI+1, 2HI+1)
i = 0
while i < GOAL
x = rand(-HI:HI)
y = rand(-HI:HI)
LO^2-1 < x^2 + y^2 < HI^2+1 || continue
i += 1
canvas[x+HI+1, y+HI+1] = true
function printcircle(lo::Integer, hi::Integer, ndots::Integer; pad::Integer = 2)
canvas = falses(2hi + 1, 2hi + 1)
i = 0
while i < ndots
x, y = rand(-hi:hi, 2)
if lo ^ 2 - 1 < x ^ 2 + y ^ 2 < hi ^ 2 + 1
canvas[x + hi + 1, y + hi + 1] = true
i += 1
end
end
# print
for i in 1:(2hi + 1)
row = map(j -> j ? "\u25cf " : " ", canvas[i, :])
println(" " ^ pad, join(row))
end
return canvas
end
for i in 1:(2HI+1)
println(" ", join(map(j -> j ? "\u25cf " : " ", canvas[i,:])))
end
printcircle(10, 15, 100)