# Priklad 11

n <- 1000

par (mfrow = c(1,1), mar = c (4,4,4,1))
plot (c(0, 24), c(0, 24), type = "n", xlab = "kamion A", ylab = "kamion B")

A <- runif (n, 0, 24)
B <- runif (n, 0, 24)

V <- data.frame (cbind (A, B))
V$ok <- ( (V$A - 2 <= V$B) & (V$B <= V$A + 1) ) | (V$B <= V$A - 23) | (V$A + 22 <= V$B)
V$color <- ifelse (V$ok, "#00cc00", "#ff0000")
V$symbol <- ifelse (V$ok, 1, 4)

points (V$A, V$B, col = V$color, pch = V$symbol, lwd = 2)
nA <- sum (V$ok)
fA <- nA / n
title (main = paste (nA, "/", n, "=", fA))
