How do you find the difference in degrees between two headings?
Figured it out.

LH turn: [origin hdg] - [destination hdg] (if less than 0, add 360)

RH turn: [destination hdg] - [origin hdg] (if less than 0, add 360)

Edit: for the acute angle between two headings you would just take the lower number between these two values.   There is no different formula.   This is alluded to in this SO post.

By the way, this is not really useful for normal pilots because you can just visualize a compass rose and figure out the different angles pretty easily but I am making a program that will make flying holding patterns a lot easier.   You input the inbound leg course (not radial), the wind (direction, velocity), your true airspeed, and whether you are making a left or right hand turn.   The program calculates what heading you should turn to on the outbound leg and the heading you should then turn to on the inbound leg (assuming standard rate turn).   It also gives you the time to fly on the outbound leg after you reach your heading for that leg.   It even takes into account turning from/to different crab angles (which would make the turns more or less than 180 degrees).