Here's the question: Given some number of identical balls $1 < n\leq \frac{u}{2}$, how many ways can you distribute them into a line of urns $u$ such that no two adjacent urns contain balls, and each urn may contain only 1 ball.
Alternatively: given the same constraints on $n$, what is the probability that the urns will contain a run of at least 2 adjacent balls (the real problem I'm trying to solve).
My attempt thus far:
The way to compute the ways we can order the balls is a combination $u\choose{n}$, since the balls are indistinguishable. The first part of the problem may be an easier (or harder formulation) but I tried to tackle it with the understanding that I could use the following setup:
$$\frac{{u\choose{n}} - part1}{u\choose n}$$
Where part1 is the solution to the first question. So, this reads: the total number of ways to arrange the balls - all the ways the balls are completely separated from each other, divided by all the configurations, to give me the probability I wanted as the solution for part 2.
I think I'm on the right track here for solving part1, but I can't confirm it's correct. I think it's just ${u-n+1}\choose{n}$. My (shaky) justification is that to guarantee there are no runs of adjacent balls, I must position the balls in a limited set of spaces, and this limit seemed right, though I'm unsure how to demonstrate it. I've done some empirical tests which seem to confirm it, and it looks like it works even for edge cases of only 1 ball (returns 0% probability), but I could seriously use a cross-check here.
All in all, my final function is the following:
$$\frac{{u\choose{n}} - {u-n+1\choose{n}} }{u\choose n}$$
And here's some Julia code that I used to "verify" it:
#Recursively checks a list for consecutive 1s, returns a list of all instances.
has_consec(x)=
length(x) > 1 ? vcat(x[1] == x[2] && x[1]==1, has_consec(x[2:end])) : return []
#filters a list of all the unique permutations of my list
#(the combinations function is funky in julia for some reason)
#by making sure there are no consecutive 1s, gets the length of the final list.
emp_test(n,y)=length(
filter(x->!any(has_consec(x)),
unique(
collect(
permutations(
vcat(repeat([1],y),repeat([0],n-y)
))))))
```