# [Charcoal], <s>115</s> 112 bytes ≔⟦⟦⟦⟧⟦⟧⟧⟧ηFEθ÷×÷⊖X⁴ι²X²κX²ι¿ι«≔⟦⟧ζFη«≔§κ¹εFΦLε¬&§ελι⊞ζ⟦⁺§κ⁰⟦λ⟧Eε⎇⁼νλ⁺μιμ⟧⊞§κ⁰Lε⊞ει⊞ζκ»≔ζη»Fη⊞§κ⁰¦⁰≔EηL⊟ιζI§η⌕ζ⌊ζ [Try it online!][TIO-l4ssmyb0] Link is to verbose version of code. Explanation: ≔⟦⟦⟦⟧⟦⟧⟧⟧η Start with no mushrooms placed. FEθ÷×÷⊖X⁴ι²X²κX²ι For each mushroom, calculate a bitmask corresponding to the space that it occupies. Edit: Saved 3 bytes by using my golf to @Arnauld's formula. ¿ι« If this mushroom occupies space, then: ≔⟦⟧ζ Start collecting placements that include this mushroom. Fη« Loop over the existing placements. ≔§κ¹ε Get the bitmasks for the heights as this gets used a lot. FΦLε¬&§ελι Find whether this mushroom can be placed at any existing height. ⊞ζ⟦⁺§κ⁰⟦λ⟧Eε⎇⁼νλ⁺μιμ⟧ Generate a placement for putting this mushroom at that height. ⊞§κ⁰Lε⊞ει⊞ζκ Generate a placement for putting this mushroom at a new height. »≔ζη Save the new placements as the current placements. »Fη⊞§κ⁰¦⁰ If this mushroom occupies no space then place it at zero height. ≔EηL⊟ιζ Get the heights of all of the placements. I§η⌕ζ⌊ζ Output one of the placements with minimal height. [Charcoal]: https://github.com/somebody1234/Charcoal [TIO-l4ssmyb0]: https://tio.run/##bVHBbsIwDD3DV@ToSJkEHTdObAwJaUw9cItyqKihEWkKTQpbJ769c9q1oGmKEsXx83v2yy5Lyl2RmKZZOKcPFqSUSjCpFJ0Zn4/3Rclgk5zgLNja@qW@6BRhq3N0cI@XuCsxR@sxhbi4YgkzwTTngkW0u5dIsCN/jCjPOdN7Bpqz7/Go74CUa1IetdJZm@pzC7@2KX7CUbApUWGAdbiVNp5o39EefAZIyY/Cw4v2V@1wYdOhFAUzvBePK5dBTfPGpnKP7BOCSKPoDLNTzRZLm5Rf8HauEuPAdixtWR7YBMs5V20/LekfrqGvOwJD2RDVwR2KboMPdfcBtzEah6w34z/yCcF@i0K32SAXFycIg3aGxqW2Hl4T5wcCgq40mUNaG211XuVQB2P4vGmkjERYE1oz2s90nyrVPF3MDw "Charcoal – Try It Online"