## a non-riddle

**U**nless I missed a point in the last riddle from the Riddler, there is very little to say about it:

Given N ocre balls, N aquamarine balls, and two urns, what is the optimal way to allocate the balls to the urns towards drawing an ocre ball with no urn being empty?

Both my reasoning and a two line exploration code led to having one urn with only one ocre ball (and no acquamarine ball) and all the other balls in the second urn.

odz<-function(n,m,t) 2*m/n+(t-2*m)/(t-n) probz=matrix(0,trunc(N/2)-1,N-1) for (n in 1:(N-1)) for (m in 1:(trunc(N/2)-1)) probz[m,n]=odz(n,m,N)

July 14, 2019 at 4:57 pm

That’s what I did for the same problem:

library(tidyverse)

library(ggalt)

data.frame(rnum = rep(1:99, 49), cnum = rep(1:49, each = 99)) %>%

mutate(setup = paste0(“Col”, cnum)) %>%

mutate_at(vars(setup), factor, levels = paste0(“Col”, 1:49)) %>%

mutate(value = map2_dbl(

cnum, rnum,

~ {

ifelse(.y 50 + .x, NA, 1 / 2 * .x / .y + 1 / 2 * (50 – .x) / (100 – .y))

}

)) -> my.df

colors <- colorRampPalette(c("#3288bd", "#ffffbf", "#d53e4f"))(length(levels(my.df$setup)))

ggplot(my.df, aes(x = rnum, y = value, group = setup, color = setup)) +

geom_xspline(spline_shape = -0.4, size = 0.5) +

scale_colour_manual(values = setNames(colors, levels(my.df$setup))) +

theme_bw()

July 14, 2019 at 7:48 pm

Thanks, but I am unable to install ggalt…

July 13, 2019 at 8:10 am

[…] article was first published on R – Xi'an's Og, and kindly contributed to […]