Originally shared on the public FactorioPrints / Factorio School archive (factorioprints.com · factorio.school). Authorship preserved from the public catalog.
Counts the number of occupied slots in an container's inventory.
Attach contents signal to green wire on the constant combinator, and the red wire from the constant combinator will output the count of inventory spots the green signal will occupy on the N signal. Doesn't work with stacks that were split manually.