Science of gingerbread houses