Solution for Halloween Party problem