This is the basis of most distributed random number selection algorithm, which existed since a lot before blockchains.
In a smart contract, it could look like something like that:
1- each person which want to participate in the bet pick a random number, then send: their bet (0 or 1), the hash of the random number, and of course money to bet.
2- after some specified time, the first phase finish and no new person can bet. now everyone has to send their actual random number to the smart contract
3- after some specified time again, every random number gathered which had the correct hash are xored. If the popcount of the result is even, 0 win. otherwise 1 win. Everyone who send their random number and guessed correctly get a share of the total amount.
edit: note that I'm not overly familiar with smart contracts, so if this cannot work I would love to be explained why.