Probably biggest problem was automatic handling of free space. You have X^Y combinations to check. Last time I worked on this it did needed lot of testing to work correctly. And testing is not thing that programmers like doing :>
Would this still be a problem if the sizes are exclusive? As in, only one size can be assigned per craft/hangar?
Default/vanillar hangar or non-defined size defaults to 1, number of free slots per hangar also defaults to 1 if not assigned to not break compatibility. Check the largest hangar size and max. number of total hangar slots per size, create an array with 1:[largest size] lines and 1:[max. hangar slots] columns. Write a 1 for every free slot per size. The sum of the array gives you your total slots.
Do the same for the crafts. Pad both arrays accordingly. Substract the craft array from the hangar array. The sum of the resulting array is your (total) free hangar space. Check the sums of the individual line vectors. If any of those are 0 or negative there is no free space for that type of craft.
Disclaimer: Above is (a probably overcomplicated way of) how i would implement this in matlab. I'm very bad at matlab and have no idea how this should actually be implemented.You could always allow multiple sizes later on, but i for one would be happy to even be able to assign one type of size per craft/hangar. I think having multiple sizes per hangar while also having multiple slots per hangar might be overly complicated, at least for an initial implementation.