Algorithms for Random Generation and Counting door