Exact Bayesian regression of piecewise constant functions