How many times will a bell tower ring?
JavaScript (ES6), 38 35 bytes

f=(x,y)=&gt;~-x%12-~(x-y&amp;&amp;f(x%24+1,y))


Recursively adds the current number of bell rings to the total. Called like f(11,15); midnight is represented as 24. I got part of the ~- trick from @xnor's Python answer.

Test snippet



f=(x,y)=&gt;~-x%12-~(x-y&amp;&amp;f(x%24+1,y))
g=(x,y)=&gt;console.log("x:",x,"y:",y,"result:",f(x,y))

g(10,12)
g(1,5)
g(11,15)
g(22,10)
&lt;input id=A type="number" min=1 max=24 value=9&gt;
&lt;input id=B type="number" min=1 max=24 value=17&gt;
&lt;button onclick="g(A.value,B.value)"&gt;Run&lt;/button&gt;




Non-recursive version (Firefox 30+), 56 bytes

(x,y,t=0)=&gt;[for(_ of Array((y-x+25)%24))t+=x++%12||12]|t


Equivalent to the following ES6 function:

(x,y,t=0)=&gt;[...Array((y-x+25)%24))].map(_=&gt;t+=x++%12||12)|t