a non-riddle

Unless 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)

3 Responses to “a non-riddle”

  1. ΓΔ 047 Says:

    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()

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.