Brain teasers

Expected sum of distances in a triangle.

Question: Triangle ABC has sides of length 45, 60, and 75. Place a point D randomly and uniformly inside the triangle. What is the expected value of the sum of perpendicular distances from point D to the triangle’s three sides?

fishy

#include "presets.h"
#include <iostream>
#include <gsl/gsl_math.h>
#include <gsl/gsl_rng.h>
gsl_rng *r;
void setup_rng() {
    gsl_rng_env_setup();
    const gsl_rng_type * rng_type = gsl_rng_default;
    r = gsl_rng_alloc (rng_type);
}
double avg_sum_of_distances(int repeats) {
    double sum = 0.0;
    auto i = 0;
    while (i < repeats) {
        auto x = gsl_rng_uniform (r) * 45;
        auto y = gsl_rng_uniform (r) * 60;
        if (y > 60 - 4*x/3) continue;
        i++;
        auto h = 36 - 3*y/5 - 4*x/5;
        sum+= (x+y+h);
    }
    return sum/repeats;
}
setup_rng();
auto avg = avg_sum_of_distances(1e7);
std::cout << avg << std::endl;
gsl_rng_free (r);
47.0007